Lesson 5 Automatic Temperature Based Door Opener - Water-Monitor/IoT-Portfolio-FJS GitHub Wiki

We had to replace the Node-Red code that we had with actual sensors: A temperature sensor, a Relay and something attached to the Relay.

Step by step...

  • Open Arduino and open the library manager
  • Search for 'pubsubclient' (version 2.8.0)

Meanwhile we had some troubleshooting with the wifi connection and needed to re-install Arduino.

  • In Arduino: Open the examples > pubsubclient > mqtt ESP8266
  • Add the SSID and the password (iotjs & internethofthings7)
  • Change the mqtt_server ip = 192.168.12.1
  • Connect with esp8266
  • Open the serial monitor
  • Go to Git Bash and enter 'ssh [email protected]'
  • Then enter in Git Bash: 'mosquitto_pub -h 192.168.12.1 -t inTopic -m hey

It should now display the message on the monitor.

Connect the dallas sensor with arduino

  • Get a breadboard and a DS18B20 shield
  • In Arduino: look for a DS18B20 library (Dallas Temperature)
  • Search for the correct port of the sensor (Change from 10 to D2)
  • Make sure to plug in the sensor correctly (was upside down on the wemus)

Connect mqtt with the dallas sensor

  • Change time-settings so that the time-chart will display the time correctly
  • Get the loop() function from the example library (which reads the temperature and add it to the mqtt example
  • Change the void function into a float function
  • Create and define 'temp' with the new function from the library
  • Change the message from "hello..." into "%f" to display float values
  • The Output can be seen on the serial monitor

Connect mqtt with temp and relay

  • Create a new mqtt example in Arduino
  • Change the LED port into D1
  • Change inTopic into "switch"
  • In Git Bash: enter 'mosquitto_pub' and 'sub'. Send in any number as a message to get a "click" from the relay.

If you change the topics name into "temp" like before, it will be connected to the node-red. However, the relay won't switch if the temperature gets colder. Changing the topic into "onof", which already existis in node-red, gets 0&1 information to the switch. Therefore, the node-red switch and the relay switch will both work at the same time.

OLED example

In this task, we were supposed to add a OLED screen to our system. However, this has been only accomplished by Fadi and Stijn and was for the others more an optional task. I (Johanna) started pluggin it into the laptop but haven't finished the example ever.

Reflection Stijn

We first all three tried to make the temperature sensor working on our own. Johanna found a library and we all started to use that one and a little bit later Johanna was able to get it working. I also got something working, but it was really inaccurate and meassuring -270 degrees. So I followed Johanna's example and continued on that.

Fadi and I worked together to get the Relay working and later a door opener and a water pump. We had some confusing about the wiring from the dooropener and the water pump to the relay, but with a bit of help from the teacher we made it working.

setup