Here i have interfaced two sensors, accelerometer and temperature sensor with Telosb mote using parallel I2C connection. Zigbee part is also integrated with the program.
Connection
TMP102 GND -> TELOSB 9 pin (GND)
TMP102 VCC -> TELOSB 1 pin (VCC)
TMP102 SDA -> TELOSB 8 pin (SDA)
TMP102 SCL -> TELOSB 6 pin (SCL)
TMP102 ADD0 -> TELOSB 9 pin (GND)
TMP102 ALT -> Left unconnected
ADXL345 GND -> TELOSB 9 pin (GND)
ADXL345 VCC -> TELOSB 1 pin (VCC)
ADXL345 CS -> TELOSB 1 pin (VCC)
ADXL345 SDA -> TELOSB 8 pin (SDA)
ADXL345 SCL -> TELOSB 6 pin (SCL)
ADXL345 SDO -> TELOSB 9 pin (GND)
The circuit i created for interfacing the sensors with Telosb is given below. I have used an intermediate interfacing board for connection.
Program
Transmitter Program
Programming is done with Nesc in TinyOS. Four main files are here I2CAPPC.nc, , I2CC.nc, I2CRadio.h and Makefile.
I2CAPPC.nc
I2CAPPC.nc
I2CRadio.h
Makefile
Connection
TMP102 GND -> TELOSB 9 pin (GND)
TMP102 VCC -> TELOSB 1 pin (VCC)
TMP102 SDA -> TELOSB 8 pin (SDA)
TMP102 SCL -> TELOSB 6 pin (SCL)
TMP102 ADD0 -> TELOSB 9 pin (GND)
TMP102 ALT -> Left unconnected
ADXL345 GND -> TELOSB 9 pin (GND)
ADXL345 VCC -> TELOSB 1 pin (VCC)
ADXL345 CS -> TELOSB 1 pin (VCC)
ADXL345 SDA -> TELOSB 8 pin (SDA)
ADXL345 SCL -> TELOSB 6 pin (SCL)
ADXL345 SDO -> TELOSB 9 pin (GND)
The circuit i created for interfacing the sensors with Telosb is given below. I have used an intermediate interfacing board for connection.
Program
Transmitter Program
Programming is done with Nesc in TinyOS. Four main files are here I2CAPPC.nc, , I2CC.nc, I2CRadio.h and Makefile.
I2CAPPC.nc
#include "I2CRadio.h" configuration I2CAppC{ } implementation { components MainC, I2CC as App; App.Boot -> MainC; components LedsC; App.Leds -> LedsC; components new TimerMilliC() as I2CTimer; App.I2CTimer -> I2CTimer; components new ADXL345C(); App.axis -> ADXL345C.XYZ; App.AccelControl -> ADXL345C.SplitControl; components new SimpleTMP102C(); App.Temp -> SimpleTMP102C.Read; components new AMSenderC(AM_I2C); App.Packet -> AMSenderC; App.AMPacket -> AMSenderC; App.AMSend -> AMSenderC; components ActiveMessageC; App.AMControl -> ActiveMessageC.SplitControl; components new AMReceiverC(AM_I2C); App.Receive -> AMReceiverC; }
I2CAPPC.nc
#include "printf.h" #include "ADXL345.h" module I2CC { uses { interface Boot; interface Leds; interface Timeras I2CTimer; interface Read as axis; interface SplitControl as AccelControl; interface Read as Temp; interface Packet; interface AMPacket; interface AMSend; interface SplitControl as AMControl; interface Receive; } } implementation { bool busy = FALSE; message_t pkt; uint16_t counter = 0; nx_uint16_t X; nx_uint16_t Y; nx_uint16_t Z; nx_uint16_t Tem; event void Boot.booted() { call AccelControl.start(); } event void AccelControl.startDone(error_t err) { printf("\n\n------Accelerometer started-----\n\n"); call I2CTimer.startPeriodic(1000); } event void AccelControl.stopDone(error_t err) { } event void I2CTimer.fired() { counter++; call Leds.led0Toggle(); call axis.read(); } event void axis.readDone(error_t result, adxl345_readxyt_t data) { if (result == SUCCESS) { X = data.x_axis; Y = data.y_axis; Z = data.z_axis; printf("\nX [%d] Y [%d] Z [%d]\n",X,Y,Z); call Temp.read(); } else printf("Error in reading Accelerometer sensor\n"); } event void Temp.readDone(error_t err, uint16_t temp) { if (err == SUCCESS) { call Leds.led1Toggle(); temp=temp*6.25; Tem=temp; printf("Temperature = %d.%d\n\n",temp/100, temp%100); printfflush(); call AMControl.start(); } //***************AM Part******************** else printf("Error in reading Temperature sensor\n"); } event void AMControl.startDone(error_t res) { if (res == SUCCESS) { // printf("****AM STARTED****\n"); if (!busy) { I2CRadioMsg* i2cpkt=(I2CRadioMsg*)(call Packet.getPayload(&pkt,sizeof(I2CRadioMsg))); i2cpkt -> counter = counter; i2cpkt -> xaxis = X; i2cpkt -> yaxis = Y; i2cpkt -> zaxis = Z; i2cpkt -> temp = Tem; if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(I2CRadioMsg)) == SUCCESS) { busy = TRUE; call Leds.led2Toggle(); } } } else { call AMControl.start(); } } event void AMControl.stopDone(error_t error) { } event void AMSend.sendDone(message_t* msg, error_t error) { if (&pkt == msg) busy=FALSE; call AMControl.stop(); } event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) { } }
I2CRadio.h
#ifndef I2CRADIO_H #define I2CRADIO_H typedef nx_struct I2CRadioMsg { nx_uint16_t counter; nx_uint16_t xaxis; nx_uint16_t yaxis; nx_uint16_t zaxis; nx_uint16_t temp; }I2CRadioMsg; enum { AM_I2C = 7, }; #endif
Makefile
COMPONENT=I2CAppC CFLAGS += -I$(TOSDIR)/lib/printf CFLAGS += -I$(TOSDIR)/chips/adxl345 CFLAGS += -I$(TOSDIR)/chips/tmp102 include $(MAKERULES)
could u help me in how to interface PR senor to telosB
ReplyDeletecould u please help me how to interface PIR sensor with telosB
ReplyDeleteInterconnecting PIR with Telosb is pretty straight forward. Connect the o/p pin of PIR to any of the GIO pin of telosb.
ReplyDeleteU can refer my post on "GIO Input and Output of TelosB" for using GIO of Telosb. While any movement is detected by PIR it will give a high value to the Telosb GIO i/p, and other wise a low value.
If u need further clarification plz reply.
Hi I have problem with ADXl345 drivers after all modifications on adxl345 package to make it compatible for telosb I always getting fix numbers like 14848 for all axis . I need to make ot run for my university project could you please help me in this ? I guess You did some modification on the adxl345 dirver package would you please guide me how to make package compatible to telosb ?
DeleteHow to connect HMC5883L(which is a 3-axis magnetometer) to telosB and is exist any driver for compatibility? and to make MAKEFILE? how to check the makefile content is present or not? i am getting an error in makefile?
Deleteerror:printf is not exist but i checked in tinyos/lib/printf but it present there..
Hi I have problem with ADXl345 drivers after all modifications on adxl345 package to make it compatible for telosb I always getting fix numbers like 14848 for all axis . I need to make ot run for my university project could you please help me in this ?
ReplyDeleteHi,
ReplyDeleteI am trying to interface Soil moisture sensor with TelosB Motes.
I need to read Analog value frm the sensor connected via ADC0 port of GPIO telosb pins.
The components HplMSP430C is used to get only digital values.
I need to combine Read interface with HplMSP430 to get the analog values.
Is it Possible? Or is der any other components to read the analog values.
Kindly suggest.