Adding Light sensor to the HC-12 + Temp sensor

In one of the previous articles, I’ve shown you how to read the temperature and send it (very basic format) through HC-12 transmitter.

Now we could easily add Light reading and sending it to the reader ( Another HC-12, hooked to Raspberry PI or Arduino )

 

 

For that purpose, we will use BH1750 sensor. It’s very easy to hook it to Arduino, read the values and send it, along with the temperature reading.

BH1750 uses I2C and is very easy to connect:

  • VIN – Connect to Arduino 3.3V
  • GND – Connect to Arduino GND
  • SCL – Connect to Arduino A5
  • SDA – Connect to Arduino A4

So now we will have two sensors, connected to the I2C bus, but they use different addresses, so no conflicts will occur. However, you could easily connect two BH1750’s if you connect ADDR to low on the one and ADDR to high on the other. For our test purposes, we’ll only use one. You can leave ADDR not connected, it’s low by default.

So, I’ve modified the send script a bit. First, you need to add the library for BH1750 reading, by downloading the ZIP file and importing it to Arduino IDE. Then, flash the following file to the sensor. It’s very basic and you can modify it by your liking, of course. In it’s current form, it will send temperature reading, then after 5 seconds – the light reading, then – after 5 seconds – temp reading again and will cycle. In the real life, you might want to make that around 1 minute for the full cycle, or even more.

Then if we use this, we can show both readings on the LCD. Or we could use the HC-12, connected to the Raspberry PI directly and send that to Domoticz.

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar