I am chaos. I am the substance from which your artists and scientists build rhythms. I am the spirit with which your children and clowns laugh in happy anarchy. I am chaos. I am alive, and I tell you that you are free.
It’s a rainy weekend… The bicycles tracks are muddy and the bees are locked inside and probably eating all the honey they gathered 🙁
Perfect weather to learn something new… and it has been on my bucket list for a while. Developing dapps on the computer network. In case you don’t know about ICP yet, It’s a project lead by the “dfinity foundation” to develop a decentralized network computer, basically cloud services+blockchain. 3 years back, I was a bit skeptical about the technical challenges… they have come a long way.
In simple terms, ICP is a decentralized cloud using “canisters” to host dapps, “cycles” as units of compute and ICP tokens to monetize the service. If you host canisters, you get paid with ICP tokens. That brings TaaS (Transaction as a Service) as a natural evolution to SaaS. This means every dapp visitor/user will consume cycles and you are motivated to create economically viable content and services.
The question of Compliance and Legal Jurisdiction remains open… Although in theory the canister can run anywhere, and scale… certain laws will apply sooner or later and probably it will be the law of the mighty.
ICP Terminology
Real World equivalent
Canister
Kubernetes?Docker?
Cycle
Compute
Identity
Active Directory
Motoko
any programming language
nns
neural network (just a fancy name for network)
ICP
the token that can be staked like ETH
Voting
like proof of stake in ETH, your tokens allow you to vote on the maintenance and evolution of the network
Dfinity
the foundation that is promoting and governing ICP
Its been a great day to day! lots of problems solved…
Target is to log the sensor data form the nodemcu esp8622 / arduino into google drive on a sheet for visualization.
it consisted of 3 steps:
creating the google form
creating the Arduino Sketch to get the sensor data and send it using wifi to the internet
create a php middleware to handle the https connection to google
Create a form in google drive to log the data ur sensors provide, in my case i created humidty and temperature, what is delivered by the DHT11 sensor. heres a link to my form https://docs.google.com/forms/d/1rv-vuoiAbHI8I9nkGXjb3nMB8LFn7-jh20fYDdm9Kcg/, the nice thing here is that google will create a sheet to store the data, give them a timestamp and provides “insights” to analyze the data. AND you can publish them on the internet, share them…
in the form, make sure the answers are text
note ur form id 1rv-vuoiAbHI8I9nkGXjb3nMB8LFn7-jh20fYDdm9Kcg
open the form page source and look for the field names : in my case its “entry.2067116456” every field has unique number after “entry.”, you’ll need these to fill the form
test a GET URL like this to fill the form (replace the form id and the field id with urs), mine looks like this https://docs.google.com/forms/d/1rv-vuoiAbHI8I9nkGXjb3nMB8LFn7-jh20fYDdm9Kcg/formResponse?ifq&entry.997762564=33&entry.2067156456=66 -> here you see that i have changed the field numbers to avoid abuse.
Now you see, its easy to get the nodemcu to call this URL and transmit the variables humidity and temperature to googleforms, google will do the rest. The bigger problem is that google changes the forms every now and then and doesnt support http… and i want to keep node as small as possible…. so i opted for a PHP middleware that gets the http request from the node and forwards it in https to google.
Heres the php code:
<?php // create a new cURL resource $ch = curl_init();
Serial.print(“connecting to “); Serial.println(host);
// Use WiFiClient class to create TCP connections WiFiClient client; const int httpPort = 80; if (!client.connect(host, httpPort)) { Serial.println(“connection failed”); return; }
float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature();
Serial.println(h); Serial.println(t);
// We now create a URI for the request String url = “http://beedata.yazbek.com/data/XXX.php?”; url += “h=”; url += h; url += “&t=22”; url += t; //url += value;
// This will send the request to the server client.print(String(“GET “) + url + ” HTTP/1.1rn” + “Host: ” + host + “rn” + “Connection: closernrn”); delay(1000);
// Read all the lines of the reply from server and print them to Serial while (client.available()) { String line = client.readStringUntil(‘r’); Serial.print(line); }
After reading about lua programming language and its downturn in mcu (bugs and lack of space and code libraries) and after a clear sign from Benrnhard, i decided to switch to the Arduino IDE and its C libraries.
So let me try to setup a temperature/humidity sensor today….
Went to File -> Preferences -> Additional Boards Manager URLS, added the link http://arduino.esp8266.com/stable/package_esp8266com_index.json now search for it and waaaaaaiiiit (5-10 min) for it to download and install, now u can choose it from the Board menu.
installed the DHT11 sensor and used the File-> examples -> DHT sensor library -> DHTtester
adjusted some lines with the sensor type and now its working.
Flash the Node as mentioned in the video, and the paste the code below…
while 1 do gpio.write(0, gpio.HIGH) tmr.delay(100000) — wait 1,000,000 us = 1 second gpio.write(0, gpio.LOW) tmr.delay(1000000) — wait 1,000,000 us = 1 second end
voilà… its flashing.
now I had to reset the node to get it back to normal 🙂