Posts

Showing posts from April, 2021

Arduino DHT22 readings over serial

Image
 Today I am going to add a DHT22 temperature humidity sensor to my existing battery voltage monitor project. Uploading and testing the code is done over USB cable, the HC-05 needs to be disconnected for this to work. The DHT22 is connected to +5v, gnd and Digital Pin 10, I only chose pin10 as it is convenient for my veroboard layout. The code for this is very simple : <code> #include "DHT.h" #define DHTPIN 2 // The pin that your DHT is connected to DHT dht(DHTPIN, DHT22); void setup() { dht.begin(); } void loop(){ float h = dht.readHumidity();     //stores humidity value in float variable h float t = dht.readTemperature();// temperature value } </code> Don't forget to import the "DHT sensor library" in library manager in the Arduino IDE.  We can then do whatever we need to with the values. I am going to send request them over serial via a HC-05 Bluetooth device from a Python script on a Raspberry Pi.  For testing  am using a laptop running ...

Laptop to Arduino Nano with HC-05 Bluetooth Module

Image
 After getting a serial connection to work between an Arduino Nano and Pi Zero in a previous project I purchased a HC-05 Bluetooth module so that the Pi can be removed from the enclosure, this should reduce the power requirement significantly resulting in increased battery life. Power requirements : Pi Zero, Arduino Nano 290mA Arduino Nano, HC-05 module Bluetooth Module 50mA The power reduction is huge but it is a bid of a mess when soldered onto veroboard. (I have ordered a few ESP32 for a future improved version.) The wiring diagram is very similar, just replace the Pi Zero with the HC-05 as below. You can ignore everything to the right of the Nano, it is not required for Bluetooth but i am using it to retrieve a battery level reading. When powered up the led on the HC-05 should flash rapidly indicating ready to connect. To test you can use the Android app "Serial Bluetooth Terminal". The default pairing code is "1234". I will be using Python to communicate with t...

Calculating Battery for Small Solar Project

Image
 Today is about planning the power side of a Raspberry Pi Zero W and Arduino Nano (Elegoo clone) greenhouse monitor. We need to calculate the battery and solar panel size so that it can run continually in the UK at least over the summer months. I have measured these figures to give us somewhere to start the calculations : Pi Zero W power draw low 90ma, med 118ma, high 193ma Arduino Nano Clone, running 1x ADC and serial 21ma  Full project usage 280ma :o this includes 12 to 5v switching voltage regulator  280ma is more than I was hoping for, maybe I will look in to reducing this by using a better voltage regulator (without an LED display etc). For now this is what I have to work with, lets add a small margin and call total current draw 300ma. We have around 8 hours a day sunlight hitting the panel so the rest of the time it will be running on battery. 24 - 8 = 16 hours absolute minimum battery = 16 * 300 = 4800mah = 4.8Ah  The cost of a 5Ah lead acid battery from RS Co...

Connecting Raspbery Pi to Arduino over serial pins / GPIO

Image
Warning ! the Raspberry Pi operates on 3.3v and the Arduino on 5v. Connecting the TX RX pins directly will damage the Pi!  Today we will be connecting a Raspberry Pi ZeroW to an Arduino Nano (Elegoo Clone) over serial interface to enable two way communication. We will test this using the previous voltage divider project .  To accomplish this we will need the following: Raspberry Pi Arduino Nano Logic level converter Breadboard + jumper wires Power supplies for each The wiring diagram is as follows :  I have set it out on a bread board as follows using the 3.3v and ground of the Arduino instead of a battery for the divider measurement.  The GPIO serial pins on the Pi need to be configured before we can use them. To do this connect / ssh into your Pi and run "sudo raspi-config". Select "3 Interface Options", then "P6 Serial Port". Would you like a login shell to be accessible over serial, select "No". Would you like serial port hardware to be enab...

Reading an Analogue Voltage with Arduino over USB Serial

Image
  The purpose of this mini project is to check that we can read the analogue signal from the voltage divider that was made previously . Transfer the value via serial connection and perform a calculation to check against measured values.   The circuit diagram is as follows :   To start, the voltage divider is connected to a 5v supply and analogue pin A0 of an Arduino Nano 3. In the Arduino IDE the code is as follows : const int pinA0 = A0;       // Analogue input pin that the battery is attached to int vBattery = 0;            // This will be our voltage reading. int incomingByte = 0;   // Holds the request void setup() {   Serial.begin(9600);                          // Start serial communications   Serial.println("Request reading by sending a request");   Serial.println("Pin A0, Battery = b"); } void loop()...