Sending Data to Thinger.io

The final step of our project was to connect everything to our NodeMCU esp8266. As the Node is a board itself, we attached the flow rate sensor, LCD and LEDs to its D pins and shared the power between the Arduino and the Node. We then changed our code to correspond to the amendments we made.

 

Screen Shot 2018-04-17 at 18.28.59.png

 

Troubleshooting

Once connected, we had the problem that the flow rate sensor was not responding and not giving any readings. We knew this because when opening the serial monitor there were no readings being taken. After analysing the new setup, we narrowed down the possible reasons for this below:

  • LCD sucking power from the Flow Rate Sensor
  • Need external power
  • Pins on the NodeMCU esp8266 doesn’t support interrupt pins
  • Code was wrong

Firstly, we took the LCD out of the setup and ran the code again which proved not to be the problem. Next was applying an external power supply which again made no difference.

On the Arduino, the interrupt pins are mapped to pins 2 and 3 whereas the Node after some further research we found out that it didn’t specifically have any interrupt pin but it was the code relating to the interrupt that had to be changed. So because of this we needed to change the syntax to allow the flow rate sensor and the esp8266 to communicate with each other. As you can see below, the change was very simple but without it it would never work. We found the new code by looking up the syntax for the esp8266 interrupt.

Old Line of Code

attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

New Line of Code

attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING);

 

Sending Data to Thinger.io

Sending data to thinger.io is a fairly simple process, Thinger.io supply lines of code published on their website which allowed us to define the sensor we were using and the data we wanted to transmit on the dashboard. Below is the line of code we used to transmit our data.

Code Supplied

thing[“variable”] >> outputValue(myVar);

Our Code

thing[“sensorPin”] >> outputValue(totalLitres);

To set up a dashboard widget, it uses the “sensorPin” as what its reading and the “totalLitres” as whats it displaying.

Below is a video showing our dashboard in use:

 

Although we did want to display more than just the total litres used, we were unable to because each widget uses one sensor and as all the data comes from the flow rate sensor we couldn’t display more than one set of data. But using this dashboard shows the potential it has and is a great way for the user to check how much water is being used when they are away from the LCD.

Link to the dashboard:

https://console.thinger.io/#/dashboard/SmartWaterSensor?authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJEYXNoYm9hcmRfU21hcnRXYXRlclNlbnNvciIsInVzciI6IkphY2sxYmF0ZXMifQ.qVCIr4JTv0HmqcpDLZt-Sj1E_nK9JB2WbQ2sA7VLgHc

Full code:

https://create.arduino.cc/editor/jackrichardbates/fd7d324a-80a5-4401-8ed4-c0c36de89b75/preview?embed

 

 

 

 

 

Changing Behaviours

How Does it Change Behaviour?

In our project, we set out to change the mindsets of users by directly showing them the amount of water they are using and how much they were spending. This would then urge them to use less water as they are now able to see the cost of their actions, of which they previously may not have known and therefore making our prototype sustainable through changing behaviours.

Evidence:

A Government report published in 2012, set out explore how the implementation of “smart” electric metres changed peoples attitudes towards how they powered their homes and the changes they made because of this.

“Display in £s and pence was thought to be much more meaningful and effective as a prompt to behaviour change than display in kWh which was a largely meaningless concept to this audience. IHDs were felt to have had a role in prompting one or more of:

  •  Turning items off (at the plug) that did need to be on such as TVs, laptops, phone chargers
  • Reducing heating; for example, lower temperature, turning it off in unused rooms or in areas such as halls, stairwells, having it on for less time
  • Identifying and replacing ‘culprit’ or ‘high use’ appliances such as an ageing fridge freezer, or changing spotlights tor LEDs”

In conclusion from the findings from the report, users started turning off electrical appliances more when they were able to directly see the energy they were using and the cost behind it and therefore using less energy and becoming a ‘greener’ household.

Full Report: 

(PLEASE READ)

https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/48381/5424-smart-meters-research-public-attitudes.pdf

Connecting To Thinger.io

What is Thinger.io

https://thinger.io/

Thinger.io is an Open Source platform for the Internet of Things, it provides a ready to use scalable cloud infrastructure for connecting things. Makers and companies can start controlling their devices from the internet in minutes, without worrying about the required cloud infrastructure.

Using the Thinger.io library you will be able to connect almost any Arduino board using Ethernet, Wifi, GSM, or other supported boards like ESP8266, NodeMCU, and TI CC3200.

The client library allows connecting the IOT devices to the Thinger.io cloud platform. This is a library specifically designed for the Arduino IDE, so you can easily program your devices and connect them within minutes.

It supports multiple network interfaces and boards, like Ethernet Shield, Wifi Shield, and GSM. It also supports other boards like ESP8266 (or NodeMCU), Texas Instruments CC3200 Launchpad, and Adafruit CC3000 board. It requires a modern Arduino IDE version, starting at 1.6.3.

Installation 

The first step to start building thinger.io devices is to install the required libraries in the Arduino IDE to support exposing device resources like sensor values, lights, relays, and so on. In our case it was our Water Flow Sensor.

The easiest way to install new libraries is by using the library manager available in the Arduino IDE shown below:

Screen Shot 2018-04-17 at 15.59.00

After installation, we used an example piece of code supplied by thinger.io that would connect our Node MCU esp8266 to an available wifi network. From there we would be able to create a dashboard and start sending data supplied by the flow rate sensor. Below is the code that connected us to the wifi and the thinger.io website:

#include <SPI.h> 
#include <ESP8266WiFi.h> 
#include <ThingerWifi.h> 

ThingerWifi thing("username", "deviceId", "deviceCredential"); 

void setup() { 
thing.add_wifi("wifi_ssid", "wifi_credentials"); } 

void loop() { 
thing.handle(); }

All we had to do to use this code was to change the username, deviceId, and deviceCredential with our own credentials, and the wifi_ssid, wifi_password with the WiFi credentials.

Testing the WIFI and Commands 

Below we added 2 lines of code which allowed us to turn on and off the built in LED through the dashboard.

Declaring a control over a digital pin so we can alternate over on/off states. It is required to define the digital pin as OUTPUT in our setup code, or the resource will not work properly.

 

#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>

#define USERNAME "Jack1bates"
#define DEVICE_ID "esp8266"
#define DEVICE_CREDENTIAL "jackbates"

#define SSID "iPhone (2)"
#define SSID_PASSWORD "jackbates95"

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {

pinMode(BUILTIN_LED, OUTPUT);

thing.add_wifi(SSID, SSID_PASSWORD);

thing["led"] << digitalPin(BUILTIN_LED);
}

void loop() {
thing.handle();
}

 

 

Although this was a very large step in the right direction, we still had the matter of rewiring our circuit to the eps8266 and changing some of the code to ensure the setup works as it should.

Below is an image of what out dashboard may look like, where we could display current flow and total litres used.

Screen Shot 2018-04-17 at 16.32.57.png

 

 

Connecting to Wifi – esp8266 VS NodeMCUesp8266

The biggest challenge in our set up would be to send our data to a website to be shown graphically and help the user understand how much water they are really using. After some research, we decided to buy two WIFI enabled modules, the first being the esp8266 and secondly the NodeMCU8266. Both being part of the same family, but as we soon found out very different modules. Below is the process of connecting them both to the internet (or not) and which one we chose to use.

The ESP8266:

“This tiny and extremely cheap communication module allows you to establish a full and autonomous WiFi connection with your Arduino or Raspberry Pi microcontroller. A WiFi Serial Module works in both directions: it not only uses a TX/RX serial link to receive and send data, thus acting as a host for your WiFi applications, but can also entrust all the WiFi network-related functions to another application processor. By using serial commands, you’ll also be able to change the configurations of the WiFi Serial Module.”

At first glance, this module was quite small and didn’t really look like much, which made us a little skeptical at the start. But the module only having 8 pins and with a plethora of tutorials online we were very hopeful that this would be a quick and easy set up and we would be sending data to a website in no time.

BUT

Little to our knowledge, this module is notoriously difficult to set up. We first started with testing a simple blink test, the ‘hello world’ of the IOT community. After hours of countless failed setups and uploads, rolling back of software updates and error messages we decided we had spent too much time trying to get it to work and ditched the process there. We had read about similar issues online with no resolution which was also a factor for not using this module. Below shows the continual error message that stopped us connecting.

Screen Shot 2018-04-14 at 17.28.18

Although further research into the module showed that cheaper versions of the eps8266 had countless issues but the more expensive and ‘genuine’ modules mostly ran perfectly, so this is something to think about in the future and for anyone else looking to buy a similar moduel.

 

The NodeMCU ESP8266

“NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The term “NodeMCU” by default refers to the firmware rather than the dev kits.”

Straight out the box we were infinitely more impressed with this module and in the end was fairly easy to set up and connect to a webpage.

The Process:

Here is the online tutorial we used to firstly set up the module:

To use the module, we first had to download a series of drivers, which would allow us to communication with the module through a micro usb and give us the ability to directly upload custom code.

Next was downloading a series of libraries and board managers shown in the above video and uploading the ‘blink’ test as a first communication with the Nodemcu ESP8266.

 

Now the initial set up is complete, it should be a matter of uploading code to the Nodemcu esp8266 to connect it to the wifi which we will then use to send our raw data to a visual dashboard on a ready made website.

The IOT ecosystem contains a number of different types of companies focusing on hardware, device management, middleware, connectivity, security, analytics, and more of which we can use to display our data. Below is a list of 12 platform companies simplifying the process of implementing an IoT application which we will be considering.

  • Initial State
  • Cayenne – myDevices
  • Ubidots
  • Pubnub
  • Medium One
  • Bug Labs
  • Particle
  • MoBagel
  • Grove Streams
  • thethings.iO
  • Losant
  • Thinger.io

Week 5 – Printing the Flow Rate to an LCD

Continuing on from last week, we now had the flow rate and total flow printing to the serial monitor and the LED’S working. We now want this information to be shown on an LCD which can be placed in front of any tap to give the user a direct visual of how much water they are using.

We bought the Smraza LCD 2004 Display Module which had a built in potentiometer and supported 4 lines and 20 characters which will allow us to supply more information to the user.

Upon testing the LCD, we were blissfully unaware that this Module only needed to be connected through the pins on the back as it had an i2c add on, and not the ones on the front as first thought. Although this set us back sometime and resulted in some very strange messages being printed we soon worked it out using the below youtube tutorial and started using the below pin setup.

Wiring:

GRD – Ground

VCC- 5v

SDA- A4

SCL- A5

71QVqyV7+uL._SL1000_

 

The first step was to run a quick test to ensure the lcd was working and that it was able to print the information we wanted. Below we created a short piece of code which printed the flow rate and automatically increased it by 10ml every half second. The LCD would then print HIGH, MEDIUM or LOW, depending on the value.

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd (0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup () {
 lcd.begin(20,4); 
 lcd.print("Flowrate:");

}

void loop(){

int num = 0;

while(num <100){
 lcd.setCursor(9, 0); 
 lcd.print(num);
 lcd.setCursor(11,0);
 lcd.print("ml"); 
 
 if(num <= 20){
 lcd.setCursor(0, 1);
 lcd.print("Flowrate is LOW ");
 delay (500);
 num += 10;}

else if(num > 20 && num <70){
 lcd.setCursor(0, 1); 
 lcd.print("Flowrate is MEDIUM");
 delay (500);
 num += 10;}

else {
 lcd.setCursor(0, 1); 
 lcd.print("Flowrate is HIGH ");
 delay (500);
 num += 10;}

}}

 

After establishing the correct wiring, screen size value and libraries needed for the LCD to run, we were then ready to incorporate it into our master code and circuit. We first needed to decide what we were going to print on the LCD from the raw data we were already printing to the serial monitor.  This information had to be what would be most useful to the user, as the LCD would be placed in front of the tap they will be using. We had a choice of 4 different pieces of data we could use:

  • Current Flow Rate (litres per min)
  • Current Liquid Flowing (ml per sec)
  • Total Litres (Current period)
  • Average Usage

We decided that the ‘Current Liquid Flowing’ and ‘Total Litres’ would be the most useful for the user as it gives them direct readings of their water usage.

Applying this into our code was very straight forward and only took a small bit of manipulation of the existing code we had for the serial print. Below is the manipulated code we used to print to our LCD.

}
 
 {
 lcd.setCursor(11,0); 
 lcd.print(flowLitres*1000);
 lcd.setCursor(14,0);
 lcd.print("mL/Sec");

}
 
 {
 lcd.setCursor(0,4);
 lcd.print("Total:");
 lcd.print(totalLitres); 
 lcd.setCursor(11,4);
 lcd.print("Litres");
 }

 

IMG_0327

 

 

Screen Shot 2018-04-17 at 18.47.43.png

Full Code:

https://create.arduino.cc/editor/jackrichardbates/8fbd7876-98f5-4102-863b-269b2a0bc70e/preview?embed

 

 

 

 

 

 

 

Flashing LED’s based on Flow Rate

The first stage of our setup was to get a green and red LED to respond to the flow sensor, turning on the green LED when the water flow is good, turning on the red LED when the water flow is too high and a flashing red LED when the water flow is in excess.

As we already had out basic code for the Flow Rate sensor we could dive straight in. We knew that the flow sensor was working because we were able to print the information to the serial monitor, shown below:

 

Flow Rate sensor code:

https://create.arduino.cc/editor/jackrichardbates/ead864d5-8f40-48c7-81e1-ef9fe5cfb31c/preview?embed

Implementing the LED’s was a very simple process, we attached the red LED into pin13 and the green into pin12. We then used and ‘if else’ statement to turn on the LED’s at different flow rates.

This is shown in the below video:

Full  code:

https://create.arduino.cc/editor/jackrichardbates/58472cf5-aa60-49cc-a562-dd63d5b4da77/preview?embed

The next step in the process is to incorporate an LCD to provide real time information to the user.

Blog 1 – Smart Water Metre

Project Aim

Create a smart water metre that tracks water usage around a home and gives a live feed of whats being used and where . For this project we will focus on the main tap used in the kitchen.

Context

While we seem to be able to track many things in our life with a push of a button, our water usage isn’t one of them. Around the world, more and more cities are now experiencing major droughts leaving hundreds of thousands of people without water and they are only expected to get worse.

Taps are widely left on for long periods of time, whether this is while doing the dishes or brushing your teeth there are always savings to be made. If we had the ability to directly track what we were using on a minute by minute basis, we may be able to make small changes that can make a big difference.

Proposal Features

  • Minute by minute tracking of water consumption
  • Ability to set daily, weekly and monthly goals
  • Alerts when water consumption is too high
  • Suggestions of how to improve
  • Tangible conversions    i.e: 30litres = 85 cups of tea

Components Needed

  • Flow Rate Sensor
  • Motion Sensor
  • LCD Display

End Goal

Influence and educated people into how much water their really using and encourage them to set goals to reduce their water consumption.

 

 

 

Using IR Communication

Week 3/4

IR Transmitter & Receiver 

I teamed up with Max, who had a IR Transmitter to create a circuit which incorporated both of our modules. For our mini project we will be making a  DC Motor turn on when a push button is pressed using IR communication. Applications for this idea could be: Security doors, extractor fan systems or remote controlled toys.

thumb_IMG_0055_1024

We firstly found a setup online which gave us a good idea of how we can use our modules together and helped us with writing the code and setting up are Arduino circuit.

http://osoyoo.com/2015/03/25/ir-receiver-module/

http://osoyoo.com/2015/03/25/infrared-transmitter-module/

The setup on these websites used IR communication to turn on a LED which showed that the two modules were working together. We thought that this would be a good place to start as a prove of concept and would be a good basis for setup.

Fritzing Setup

 

Arduino Setup

thumb_IMG_0056_1024.jpg

We decided to put the setup on one Arduino rather than two shown in the tutorial as we didn’t yet know the distances the receiver would pick up the IR from the transmitter.

How it Works 

When the button is pressed, the IR transmitter sends a quick burst of IR light which is picked up the the Receiver. When this happens the LED is turned on which let us know that the two modules were working.

Receiver Code
#include <IRremote.h> //adds the library code to the sketch
const int irReceiverPin = 8; //receiver module S pin is connected to arduino D8
const int ledPin = 7; 
IRrecv irrecv(irReceiverPin);  
decode_results decodedSignal;  

void setup()
{
   Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    irrecv.enableIRIn();
}
boolean lightState = false;
unsigned long last = millis();

void loop()
{
    if (irrecv.decode(&decodedSignal) == true) //this is true if a message has been received
    {
      Serial.println(decodedSignal.value, HEX);
        if (millis() - last > 250) {
            //has it been 1/4 sec since last message
            lightState = !lightState;
            //toggle the LED
            digitalWrite(ledPin, lightState);
        }
        last = millis();
        irrecv.resume();
        // watch out for another message
    }
}

Transmitter Code
IRsend irsend;
const int buttonPin = 4; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}

void loop() {

buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
// turn LED on:
irsend.sendNEC(0x80BFA15E, 32);

}

}


In order for the the code to work we firstly had to download the IRremote library,  this allowed us to receive or transmit Infrared Remote Control codes so should be used in all code with IR communications.

 

Incorporating a DC Motor

From the code above, we wanted to add a motor to the setup so when the IR signal has been received it turns on a motor.

Fritzing Setup

thumb_IMG_0057_1024.jpg

Arduino Setup

thumb_59252723-30ED-4043-87C2-0155AC74722D_1024

In order for this to work we changed the code to incorporated the DC Motor and to only turn on when the IR signal had been received.

#include <IRremote.h>
#include <IRremoteInt.h>

IRsend irsend;
const int buttonPin = 4; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status


const int irReceiverPin = 8; //receiver module S pin is connected to arduino D8
const int Motor = 7; 
IRrecv irrecv(irReceiverPin); 
decode_results decodedSignal; 
boolean motorState = false; //motor off 
unsigned long last = millis();

void setup()
{
pinMode(buttonPin, INPUT);
Serial.begin(9600);
pinMode(Motor, OUTPUT);
irrecv.enableIRIn();
}



void loop() {

buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
 if (buttonState == HIGH) {
// turn Motor on:
irsend.sendNEC(0x80BFA15E, 32);

if (irrecv.decode(&decodedSignal) == true) //this is true if a message has been received
 {
 Serial.println(decodedSignal.value, HEX);
 if (millis() - last > 250) {
 //has it been 1/4 sec since last message
 motorState = !motorState;


 //toggle the Motor
 digitalWrite(Motor, motorState);


 }
 last = millis();
 irrecv.resume();
 // watch out for another message

}
Serial.println();

}
}



After completing the circuit and testing that it worked a couple of times, we wanted test the IR Transmitter using another circuit. Unfortunately doing this test overloaded the Transmitter and it blew the module. This then left us with the dilemma of not having a working circuit.

To overcome this we decided to use a remote which had a built in IR Transmitter  and sent out a frequency of 38kHz. Although not ideal, it worked well and allowed us to show how both IR modules worked together as seen in the below video:

 

As you can see from the video, when a button on the remote and the push button are pressed simultaneously it sends a signal to the receiver telling the DC Motor to turn on. In the video i showed that pushing the separate buttons at different times didn’t turn the DC Motor on and could only be turned on when both were pressed at the same time.

Ideally we would just press the push button to send the IR signal but unfortunately this was not possible because of the broken transmitter module.

Outcome pre broken Transmitter:

Although the circuit works well and we are happy with the outcome and how we overcame some challenges, it can be very temperamental at times and often it will take a dozen pushes of the button for the transmitter to send a signal. We are unsure as to why it does this.

Reference:

http://osoyoo.com/2015/03/25/ir-receiver-module/

http://osoyoo.com/2015/03/25/infrared-transmitter-module/

 

IR Receiver Module

‘The KY-022is miniaturised infrared receivers for remote control and other applications requiring improved ambient light rejection.’

Infrared receiver

Specification 

Operating Voltage 2.7 to 5.5V
Operating Current 0.4 to 1.5mA
Reception Distance 18m
Reception Angle ±45º
Carrier Frequency 38KHz
Low Level Voltage 0.4V
High Level Voltage 4.5V
Ambient Light Filter up to 500LUX

 

 

My first step was to understand how the IR receiver worked. to do this i found an online tutorial which controlled LED’s using my IR receiver and a remote control.

https://maker.pro/education/controlling-leds-with-an-arduino-an-ir-sensor-and-a-remote

Fritzing Setup 

Arduino-IR-Sensor-and-LEDs (1).jpg

Circuit Setup

thumb_IMG_0052_1024.jpg

Above shows my Arduino setup and the remote control i used to send IR signals to my receiver.

Code

This is the code i copy a pasted from the website. Whenever a button on the remote is pressed, the Arduino receives a code, the Arduino will compare this code with the codes already saved, and if any of them match, the Arduino will turn on the LED connected to that button.

I realised that the the code received from my remote control, was different from the code received in the tutorial meaning that the the LED’S wouldn’t turn on because the codes didn’t match.

I changed this by opening the serial monitor and taking note of the code it received when i pressed a button. I then changed the code (shown below in bold) to match what was being received.

#include <IRremote.h>
#include <IRremoteInt.h>

#define first_key 38110
#define second_key 11168
#define third_key 46114

int receiver_pin = 8;

int first_led_pin = 7;
int second_led_pin = 6;
int third_led_pin = 5;

int led[] = {0,0,0,0};
IRrecv receiver(receiver_pin);
decode_results output;

void setup()
{
Serial.begin(9600);
receiver.enableIRIn();
pinMode(first_led_pin, OUTPUT);
pinMode(second_led_pin, OUTPUT);
pinMode(third_led_pin, OUTPUT);

}

void loop() {
if (receiver.decode(&output)) {
unsigned int value = output.value;
switch(value) {
case first_key:
if(led[1] == 1) {
digitalWrite(first_led_pin, LOW);
led[1] = 0;
} else {
digitalWrite(first_led_pin, HIGH);
led[1] = 1;
}
break;
case second_key:

if(led[2] == 1) {
digitalWrite(second_led_pin, LOW);
led[2] = 0;
} else {
digitalWrite(second_led_pin, HIGH);
led[2] = 1;
}
break;
case third_key:

if(led[3] == 1) {
digitalWrite(third_led_pin, LOW);
led[3] = 0;
} else {
digitalWrite(third_led_pin, HIGH);
led[3] = 1;
}

break;
}
Serial.println(value);
receiver.resume();
}
}

 

I was then able to test this for myself shown in the video below. As you can see, when i pressed only the 1,2,3 buttons on my remote did an LED turn on as the other buttons did not send the correct key code to match what was preset in the code above.

 

I was unsure as to why the LEDs sometimes stayed on as they were programmed to only turn on and off when a button is pressed.

This test has given me a good idea of how my IR module works and how i could potentially use it for the mini project where i have teamed up with Max who has an IR transmitter.

Reference:

https://maker.pro/education/controlling-leds-with-an-arduino-an-ir-sensor-and-a-remote

KY-022 INFRARED RECEIVER MODULE

‘This module consists of a 1838 IR receiver, a 1kΩ resistor and a LED. It works together with the KY-005 IR transmitter module. Compatible with popular electronic platforms like Arduino, Raspberry Pi and ESP8266.’

https://arduinomodules.info/ky-022-infrared-receiver-module/

 

Infrared receiver

 

Infrared (IR) communication is a widely used and easy to implement wireless technology that has many useful applications. The best example in day to day life are TV/video remote controls, motion sensors, and infrared thermometers.

 

What Is Infrared? 

Infrared radiation is a form of light similar to the light we see all around us. The only difference between IR light and visible light is the frequency and wavelength, meaning that infrared light lies outside the range of visible light, so it is inviable to the human eye. A good way of seeing Infrared light is to view it through an old camera, this is because they contain a filter which makes the IR light visible, usually seen as a purple glow.

Arduino-IR-Tutorial-Electromagnetic-Spectrum-Diagram.png

 

IR Signal Modulation 

IR light is all around us, emitted by the sun, light bulbs and anything else that produces heat. So it would be easy to assume that an IR Receiver would pick up all this extra IR radiation rather than the one being sent by a transmitter. To prevent this extra radiation from interfering with the IR signal, a signal modulation technique is used.

In IR signal modulation, an encoder on the IR remote converts a binary signal into a modulated electrical signal. This electrical signal is sent to the transmitting LED. The transmitting LED converts the modulated electrical signal into a modulated IR light signal. The IR receiver then demodulates the IR light signal and converts it back to binary before passing on the information to a microcontroller as seen below in the diagram.

Arduino-IR-Remote-Receiver-Tutorial-IR-Signal-Modulation.png
IR Signal Modulation

A modulated IR signal is a series of light pulses switched on and off at a high frequency, this is known as the carrier frequency. The carrier frequency used by most transmitters is 38 kHz, because it is rare in nature and therefor can be distinguished from ambient IR noise. This way the IR receiver will know that the 38 kHz signal was sent from the transmitter and not picked up from the surrounding environment.

IR Receiver Test

I firstly wanted to test that my module was actually functional. I did this by finding a very simple circuit online which would allow me to do this.

I used a remote control form a Bose speaker as seen below to test that my module was working. When i pressed a button on the remote it sent a modulated 38kHz signal to my receiver and i could read this signal being sent using the serial monitor, this showed me that my receiver was fully functional.

thumb_IMG_0060_1024.jpg

Reference

http://www.circuitbasics.com/arduino-ir-remote-receiver-tutorial/

https://arduinomodules.info/ky-022-infrared-receiver-module/

https://learn.sparkfun.com/tutorials/ir-communication#receiving-ir-example