Saturday, March 28, 2015

[Wireless Room Temperature Monitoring System] Enclosure for wireless temperature sensor prototype

Alright, so now that i have to mess up with the code and make the code work properly, i need to have an easy to handle hardware prototype. To do so i incorporated a switch so i can put the sensor on and off without having to unplug the battery.

There it is :  The switch is available on the front side. I made a hole to have the temperature sensor stick out of the box for more accuracy.

View of the inside... pretty messy but it works


And there it is closed, the antenna is sticking out of the box through  a hole.


Until I design a 3D printed enclosure, that will do the trick. 



Monday, March 23, 2015

[Wireless Room Temperature Monitoring System] Labeling a temperature (DS18B20) from an Arduino Pro Mini to a Raspberry Pi

Back to square 1. Unfortunately the code i have been using since the beginning to send the data from the Arduino to the Raspberry Pi.

Thanks to smart people on the internet i found out there was a way to have an Arduino talk to a Raspberry Pi using the VirtualWire libraries (initially made for only Arduino to Arduino communications).

1) The Arduino part :

Download and Install the VirtualWire library : Information // Dowload Link

I uploaded the following code to my Arduino Pro Mini:
#include <VirtualWire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 3 //DS18B20 Connected to Pin 3

int compteur = 0;

const char *msg = "Temp1 ";
const char *celsius = "C: ";
const char *diese = " #";
char nombre[VW_MAX_MESSAGE_LEN];
char message[VW_MAX_MESSAGE_LEN];
char tempCx100char[VW_MAX_MESSAGE_LEN];
OneWire oneWire(ONE_WIRE_BUS); // For the DS18B20
DallasTemperature sensors(&oneWire);
DeviceAddress Thermometer = { 0x28, 0xFF, 0xED, 0x0F, 0x11, 0x14, 0x00, 0xD2 }; //Obtained using another program
void setup()
{
   Serial.begin(9600);  // Debugging only
   sensors.begin();
   sensors.setResolution(Thermometer, 10);
 
   // Initialise the IO and ISR
   vw_set_tx_pin(10);
   vw_set_ptt_inverted(true); // Required for DR3100
   vw_setup(2000); // Bits per sec
}
void printTemperature(DeviceAddress deviceAddress)
{
  compteur++;

  float tempC = sensors.getTempC(deviceAddress);
  int tempCx100 = (int)(tempC*100); // Multiply the float value to have a full int with 2 digits
  itoa(tempCx100,tempCx100char,10); //Convert int to char
  itoa(compteur,nombre,10); // compteur de message

  strcpy (message,msg);
  strcat (message,tempCx100char);
  strcat (message, diese);
  strcat (message,nombre);

  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
 
  } else {
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)message, strlen(message));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
  }
}
void loop()
{
  sensors.requestTemperatures();
  printTemperature(Thermometer);
  Serial.print(message);
  Serial.print("\n\r");
  delay(1000);
}

I basically compiled all the DS18B20 related codes i found out about earlier along with the specific code available to send stuff from VirtualWire library.
The code is sending a message with
    - a string that enables me to identify which temperature sensor sends the message.
    - the temperature as a 4 digit integer (2125 > 21.25C)
    - a message count in order to follow which messages are being lost for prototyping purposes

2) The Raspberry Pi part :

I basically used a python code suggest by this Joan on the raspberry pi forum : Link
You also need the pigpio library to be installed on the RPi : Link
wget abyz.co.uk/rpi/pigpio/pigpio.zipunzip pigpio.zipcd PIGPIOmakemake install
The code (vw.py) is a massive program which allows me to either receive or send using the RF433 Module : Link

I copied the program file in a dedicated folder on the Raspberry Pi along with another python program that will import the vw.py and once started, will only do what i need it to be doing
import timeimport pigpio
import vw
RX=27
BPS=2000pi = pigpio.pi() rx = vw.rx(pi, RX, BPS) start = time.time()print("En attente de la reception des donnees")
while (time.time()-start) < 100: while rx.ready(): print("".join(chr (c) for c in rx.get()))rx.cancel()
pi.stop()
 The result :

The Arduino Pro Mini with DS18B20 + TX433 and the relevant code is plugged in, and i start the program above and here the result :


It works ! :) Thank you to all contributor in the internet for their python programs and other libraries !

Now i can identify each temperature sensor. Next i will probably build another sensor module and try to receive both temperature and see if they don't interact too much and create a mess :)

Sunday, March 1, 2015

[Wireless Room Temperature Monitoring System] Sensor Enclosure Prototyping Part 1

I have been doing some thinking on the enclosure i want to 3D Print myself.

The goal is to have a relatively simple design to store all modules : Arduino, Temperature sensor, 9V Battery enclosure and TX RF 433 Mhz Module.

Here are the first prototype drawings :

 


I am already having second thoughts about the enclosure, specifically about the antenna. My latest test showed that i should have a linear antenna instead of a coiled one...

I will have some more drawing done in the following days.