Skip to main content

Arduino code for ESP8266 to take readings from DHT11 and upload them to InitialState.com

www.initialstate.com is a great data broker and visualization platform for IoT devices. Up until now it was out of reach for ESP8266 fans because the Arduino environment for ESP8266 did not support SSL/TLS connections. But now it does. So here is how to get HTTPS working on ESP8266 using Arduino IDE and upload readings from DHT11 every 10 seconds.

ESP8266 and DHT11
 Steps for Windows computers:

  1. Install CP2102 drivers for the USB-UART chip onboard the ESP8266 NodeMcu v1.0 board
  2. Get the latest offline Arduino IDE Windows Installer from https://www.arduino.cc/en/Main/Software
  3. Install Board support for ESP8266 in your Arduino IDE, follow instructions here:
    https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon
  4. Assemble your ESP8266 and DHT11 circuit. You will need 3 jumper cables and a breadboard to connect 3 signals from ESP8266 to DHT11 module. Connect pin marked D2 on ESP8266 to DHT11's data pin. Also supply 3.3V and GND from ESP8266 to DHT11's Vcc and GND.
  5. Plug your ESP8266 into your computer's USB port using a microUSB cable.
  6. Get a free account on www.initialstate.com, create a new bucket and make a note of the Bucket key and Access key.
  7. Download shown below and open it in your Arduino IDE
  8. Modify 4 things by supplying your own:
    1. WLAN_SSID
    2. WLAN_PASS
    3. INITIALSTATE_ACCESS_KEY
    4. INITIALSTATE_BUCKET_KEY
  9. Download the code into your ESP8266 board and watch it go! Keep the Serial Monitor within Arduino IDE open to watch what data is being sent to www.initialstate.com
Data received on initialstate.com
Watch the code go on Serial Monitor
InitialStateDHT11.ino:

Comments

  1. Please check in code in Github also.
    Very much appreciated your work.

    ReplyDelete
  2. i tried to simplify this but when i run it, on the Serial Monitor it goes that part where it says the connection is insecure.

    "Connection insecure, disconnecting, will retry..."

    I think it has something to do on Line 120 where it checks if the line is Secure. The parameter in there is the SHA 1 Fingerprint.

    May i ask how did you get that SHA1 fingerprint ? is it still updated?

    ReplyDelete

Post a Comment