this is a really old thread. I spent about 2 weeks total with mango back in 2010... I have no idea. You may want to cross post this at the arduino forum.
Latest posts made by JointTech
-
RE: Arduino is an open-source electronics prototyping platform
-
RE: Arduino and Mango Step by step working example
Nice I was struggling with setting values. Ill have to give this a try.
-
RE: Arduino and Mango Step by step working example
I would use the library here: http://www.tucsni.nl/jee/ModbusSlave.zip
other than that I have no idea. probably question better for the arduino forums as well. -
RE: Arduino is an open-source electronics prototyping platform
for posterity's sake. heres a full working example.
http://mango.serotoninsoftware.com/forum/posts/list/0/567.page#2721 -
Arduino and Mango Step by step working example
-
Buy or make a Arduino
-
Download the latest Arduino software I'm using 0020. http://arduino.cc/en/Main/Software
-
If you are using Arduino Duemilanove or a similar board that runs off USB you’ll have to install the USB drivers. You can find them in the Arduino folder you just downloaded.
-
plug in a TMP36 temp sensor as shown here: http://tinyurl.com/plbx38
Plug it into Analog port 3 instead of 0 as shown in the link. -
Grab the modbus library from http://www.tucsni.nl/jee/ModbusSlave.zip
you should check his site http://www.tucsni.nl/jee/ he actually says to use the new version here: http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
but I havent tested it. -
Unzip modbusslave.zip to your_arduino_install\libraries\ModBusSlave
-
open the arduino IDE
-
Paste the following code:
#include <ModbusSlave.h> //TMP36 Pin Variables int temperaturePin = 3; //the analog pin the TMP36's Vout (sense) pin is connected to //the resolution is 10 mV / degree centigrade //(500 mV offset) to make negative temperatures an option int temptest = 1 ; //Arduino sketch example with 2 holding regs: void setup() { /* Modbus setup example, the master must use the same COM parameters */ /* 115200 bps, 8N1, two-device network */ // regs[MB_REG0]=153; // regs[MB_REG1]=456; init_mb_slave(115200, 'n', 0); } void loop() { /* This is all for the Modbus slave */ start_mb_slave(MB_SLAVE, regs, MB_REGS); /* your code goes here */ float temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor temperature = (((temperature - .5) * 100)*1.8) + 32; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) // Serial.println(temperature); // Serial.println(regs[MB_REG0]); //printing the result // delay(100); temptest = (temperature); regs[MB_REG0]=temptest; /* handle write event */ if (written.num_regs) { /// .... written.num_regs=0; } } /* * getVoltage() - returns the voltage on the analog input defined by * pin */ float getVoltage(int pin){ return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts }
-
upload the code to your Arduino.
-
Install Mango
-
Create a new data source.
[url=http://postimage.org/image/1kmj3h7pg/] -
Create a new datapoint
[url=http://postimage.org/image/1syvr8io4/] -
you should now be seeing the current temperature updating every 5 seconds on your datapoint.
You can breathe hard on your tmp36 to see the temp go up in mango.
have fun.
hope this helps somebody as it took me about 2 days of scouring the net to make it finally work. -
-
RE: Arduino and Mango Step by step working example
-
Buy or make a Arduino
-
Download the latest Arduino software I'm using 0020. http://arduino.cc/en/Main/Software
-
If you are using Arduino Duemilanove or a similar board that runs off USB you’ll have to install the USB drivers. You can find them in the Arduino folder you just downloaded.
-
plug in a TMP36 temp sensor as shown here: http://tinyurl.com/plbx38
Plug it into Analog port 3 instead of 0 as shown in the link. -
Grab the modbus library from http://www.tucsni.nl/jee/ModbusSlave.zip
you should check his site http://www.tucsni.nl/jee/ he actually says to use the new version here: http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
but I havent tested it. -
Unzip modbusslave.zip to your_arduino_install\libraries\ModBusSlave
-
open the arduino IDE
-
Paste the following code:
#include <ModbusSlave.h> //TMP36 Pin Variables int temperaturePin = 3; //the analog pin the TMP36's Vout (sense) pin is connected to //the resolution is 10 mV / degree centigrade //(500 mV offset) to make negative temperatures an option int temptest = 1 ; //Arduino sketch example with 2 holding regs: void setup() { /* Modbus setup example, the master must use the same COM parameters */ /* 115200 bps, 8N1, two-device network */ // regs[MB_REG0]=153; // regs[MB_REG1]=456; init_mb_slave(115200, 'n', 0); } void loop() { /* This is all for the Modbus slave */ start_mb_slave(MB_SLAVE, regs, MB_REGS); /* your code goes here */ float temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor temperature = (((temperature - .5) * 100)*1.8) + 32; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) // Serial.println(temperature); // Serial.println(regs[MB_REG0]); //printing the result // delay(100); temptest = (temperature); regs[MB_REG0]=temptest; /* handle write event */ if (written.num_regs) { /// .... written.num_regs=0; } } /* * getVoltage() - returns the voltage on the analog input defined by * pin */ float getVoltage(int pin){ return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts }
-
upload the code to your Arduino.
-
Install Mango
-
Create a new data source.
[url=http://postimage.org/image/1kmj3h7pg/] -
Create a new datapoint
[url=http://postimage.org/image/1syvr8io4/] -
you should now be seeing the current temperature updating every 5 seconds on your datapoint.
You can breathe hard on your tmp36 to see the temp go up in mango.
have fun.
hope this helps somebody as it took me about 2 days of scouring the net to make it finally work. -
-
RE: Arduino is an open-source electronics prototyping platform
Hah. had to change the modbus data type in the Point Details to 2 byte unsigned integer.
Whoo hoo. I have a datapoint that is showing 123 :)
Ok I think thats good enough to know it works. I will open a new thread if I fail miserably on the next step.
thanks -
RE: Arduino is an open-source electronics prototyping platform
I feel like I'm hijacking a thread, but in my defense this will help the next guy with just enough knowledge to almost make it, ;)
I think I'm starting to get the coding part.
I "think" this should send the temperature variable to mb_reg0 and mango should be able to map graph the changing temp every 5 seconds. which is what the mango poll rate for that data source is set to.
#include <ModbusSlave.h> //TMP36 Pin Variables int temperaturePin = 3; //the analog pin the TMP36's Vout (sense) pin is connected to //the resolution is 10 mV / degree centigrade //(500 mV offset) to make negative temperatures an option //Arduino sketch example with 2 holding regs: void setup() { /* Modbus setup example, the master must use the same COM parameters */ /* 115200 bps, 8N1, two-device network */ // regs[MB_REG0]=123; // regs[MB_REG1]=456; init_mb_slave(115200, 'n', 0); } void loop() { /* This is all for the Modbus slave */ start_mb_slave(MB_SLAVE, regs, MB_REGS); /* your code goes here */ float temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor temperature = (temperature - .5) * 100; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) // Serial.println(temperature); //printing the result delay(1000); regs[MB_REG0]=temperature; /* handle write event */ if (written.num_regs) { /// .... written.num_regs=0; } } /* * getVoltage() - returns the voltage on the analog input defined by * pin */ float getVoltage(int pin){ return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts }
-
RE: Arduino is an open-source electronics prototyping platform
thanks for the reply.
I setup a data source.
[url=http://postimage.org/image/1kmj3h7pg/]and a datapoint [url=http://postimage.org/image/1kmo2396s/]
Mango is not giving me any more errors but I'm not seeing the 123 you mentioned.
[url=http://postimage.org/image/1kxsa9j0k/]could you give me one more kick in the right direction? Mango is making me feel really dense. I suppose my complete lack of understanding of M2M in general isnt helping. :)
-
RE: Arduino is an open-source electronics prototyping platform
The problem is that site gives just enough info for us noobs to know its possible. But not enough to actually get it to work. An actual working example with an arduino, LED and Mango would be nice. Look, mango can turn on this LED using this arduino sketch with the LED plugged into analog port 3. or Look, Mango can log the temp and graph it using this arduino sketch and a TMP36 sensor plugged into analog 2.
I can cut and paste and hack like a champ but I'm losing all my hair with this. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285803728/0