Page for the MacroDuino project. The aims of this project are to make it easier to get a project up and running without writing any (hopefully) code. The vision behind it is to be able to put a couple shields on an arduino, upload a sketch and have it doing what you want without spending time writing code and debugging. You could also think of it this way: if the Arduino is a rapid prototyping device than the MacroDuino code is rapid coding. You spend 5 minutes setting up the code and configuring it and you're done.
Background
The MacroDuino code is broken up into several different pieces. The first are the interfaces. Right now there are two interfaces: serial and ethernet (official ethernet shield). The second part is the control. The control function takes the input from the interfaces and parses it into a command for the arduino to execute. The nice thing about this is that in order to add another interface all you need to do is write a small function that gets the input data and formats it so the control function can understand it.
Next there are macros. Macros can be anything and right now there are quite a few of them. All macros are stored in EEPROM so there's no need to worry about setting them up again if the power goes out. Macros basically watch something (pin, time, or temperature) and perform an output based on the input.
The last part are outputs. Examples of outputs are digital pins, pins on a PCF8574, an LCD display etc. These outputs are controlled via macros (and individually).
If you find something that doesn't work let me know. I may have made a mistake in the documentation. Just use the contact link above and I'll fix it ASAP.
More Info
I'm continually doing writeups about the macroduino code and the macroduino webapp. You can follow these tags which will show you the most recent articles.
Code
MacroDuino Webapp Code on Github
Configuring The Code Video
Using The Webapp
Using Cosm With MacroDuino
Interfaces
Serial
The serial interface expects data in this format:
COMMAND/ARGUMENT1/ARGUMENT2
For example, lets say you wanted to turn pin 9 on. You would send 4/9/1.
Ethernet
The ethernet interface works almost the same as the serial interface. It expects a URL like this:
http://my_ip_address/COMMAND/ARGUMENT1/ARGUMENT2
So to turn pin 9 on you use a URL like this: http://192.168.1.100/4/9/1
Commands
The command list is quite long, but since they are all the same format it is hopefully easy for beginners to understand. If you have any questions or suggestions feel free to email me.
*all commands are numbers*
*updating documentation to reflect the new universal macro set function*
|
Command 255: Returns the Arduino's address.
Is a byte and values range from 0 - 255. Not really implemented in code yet, but will be useful if you have multiple arduinos on the same network (using something like an XBEE, this address would help you differentiate them). Example: For serial just send 255, for ethernet send http://ipaddress/255 |
|
Command 1: Set Arduinos address Syntax: 1/ARDUNOADDRESS Example: Serial- 1/110 -> sets address to 110 Ethernet- http://ip_address/1/110 -> sets address to 110 |
|
Command 2: Reset Macros Command 2 resets all the macros that have been stored on the EEPROM. It erases ALL OF THEM so use only if you really want to. |
|
Command 3: Set pinMode Command 3 allows you to set the pinMode of any of the digital pins. This pinmode is also saved to EEPROM so when you power up the arduino again it will have the same pinmodes as you had previously set. Example: Serial- 3/9/0 -> sets pin 9 as a digital input Ethernet- http://ip_address/3/9/1 -> sets pin 9 as a digital output |
|
Command 4: sets pin status (digitalWrite, analogWrite) Command 4 allows you to use the digitalWrite and analogWrite for any of the digital pins. Example: Serial- 4/9/0 -> turn digital pin 9 OFF, 4/9/1 -> turn digital pin 9 ON Ethernet- http://ip_address/4/9/100 -> does PWM value of 100 (can use this for serial as well) |
|
Command 5: Universal Macro Set command *MACRO_NAME is a maximum of 5 characters long and can't include numbers *set OUTPUT_PIN to 254 to use PCF8574 as outputs *set PCF8574_PIN to 0-7 * if you set an output action that isn't a 0 or 1 with pcf8574 arguments it won't work <>= -> Greater, Less Than, Equal To Less than = 1 Greater than = 2Equal to = 3 Watch Digital Pin Macro Syntax: 5/MACRO_NAME/1/WATCH_PIN/WATCH_STATE/OUTPUT_PIN/OUTPUT_ACTION/PCF8574_DEVICE/PCF8574_PIN/ Example: Macro NAME, Watch pin 5 for HIGH, Turn pin 9 to PWM 100 5/NAME/1/5/1/9/100 *Note: The time on argument is a delay function so your sketch will basically stop running for that amount of time Watch Analog Pin Macro Syntax: 5/MACRO_NAME/2/WATCH_PIN/WATCH_STATE/<>=/OUTPUT_PIN/ACTION/PCF8574_DEVICE/PCF8574_PIN/ Example: Macro NAME, Watch analog pin 5 for 500, if less than 500 turn pin 9 ON 5/NAME/2/5/500/1/9/1/5 DS1307 Macro Syntax: 5/MACRO_NAME/3/HOUR_START/MIN_START/HOUR_STOP/MIN_STOP/DOW/OUT_PIN/ACTION/FADE_TIME/PCF8574_DEVICE/PCF8574_PIN/ DOW refers to day of week (1 - 7). If not going to use pass 0. Example: 5/test/3/21/50/23/59/6/9/160/3/0/0/ Turn pin 9 PWM 1. Turn on at 21:50 and off at 23:59 with a fade time of 3 minutes on/off. DS18B20 Macro Syntax: 5/MACRO_NAME/4/SENSOR_NUM/<>=/WATCH_STATE_WHOLE/WATCH_STATE_DECIMAL/OUTPUT_PIN/ACTION/PCF8574_DEVICE/PCF8574_PINExample: Macro NAME, Watch sensor 3, If less than 78 degrees F turn pin 9 ON 5/NAME/4/3/1/78/00/9/1*You need to break the temperature up into the whole and half parts WATCH_STATE_WHOLE/WATCH_STATE_DECIMAL ie. 78.25 = 78/25 |
|
Command 6: Control PCF8574 pin. Syntax: 6/DEVICE#/PIN/ACTION Example: Turn pin 0 of device 0 (all pins grounded) to ON 6/0/1 |
|
Command 7: return digitalRead for pin
Syntax: COMMAND/PIN_NUMBERExample: Find out digitalRead value of pin 9 7/9 |
|
Command 8: return analogRead for pin Syntax: COMMAND/ANALOG_PIN Example: Find out analog value for pin 5 8/5 |
|
Command 9: Set DS1307 time Syntax: COMMAND/HOUR/MINUTE/SECOND/DAY/DAYOFWEEK/MONTH/YEAR Example: Set RTC to Tuesday 12:30:45 June/14/2011 (day of week for tuesday = 2 (I think)) 9/12/30/45/14/2/6/11 |
|
Command 10: Return the current time Syntax: 10 Example: Print time 10 |
|
Command 12: Display time on LCD as 12H or 24H Syntax: COMMAND/12/DISPLAY_TIME_AS Example: Display time as 12H 12/0 |
|
Command 13: Discover 1Wire devices Syntax: COMMAND Example: discover all connected 1wire devices. Addresses are stored in EEPROM so if you connect new devices just run this command and you can access them much easier. Example: discover 1wire devices 13 |
|
Command 14: 1wire devices stored in EEPROM Syntax: COMMAND Example: list all devices that are stored in eeprom. 14 |
|
Command 15: Get DS18B20 temperature reading For this command you need to run command 13 first as this command reads the address stored in eeprom. Syntax: COMMAND/TEMP_SENSOR_NUM Example: return temperature reading for the first sensor discovered 15/0 |
|
Command 16: Display time on LCD Syntax: COMMAND/DISPLAY_TIME_ON_LCD (1/0 = true/false) Example: Display time on LCD 16/1 |
|
Command 17: Column & Row to display time on LCD Syntax: COMMAND/ROW/COLUMN Example: display time on row 2, column 8 17/2/8 |
|
Command 18: Column & Row to display temperature reading 1 *note that any of the temperature readings can be assigned to whatever temperature sensor you want. Syntax: COMMAND/ROW/COLUMN Example: Display temperature reading 1 on row 2 column 8 18/2/8 |
|
Command 19: Temperature reading 1 temperature sensor Basically, you can say temperature reading 1 get the temperature from temperature sensor 5. Run the discover 1wire devices command which stores the addresses in eeprom. This way you can choose which temperatures you want to display on the LCD. Syntax: COMMAND/SENSOR_NUMBER Example: temperature reading 1 use temperature sensor 5 19/5 |
|
Command 20: Display temperature reading 1 on the LCD Syntax: COMMAND/DISPLAY_TEMPERATURE_READING_1 Example: Don't display temperature reading 1 on the LCD 20/0 (to display it use 20/1) |
|
Command 21: Column & Row to display temperature reading 2 *note that any of the temperature readings can be assigned to whatever temperature sensor you want. Syntax: COMMAND/ROW/COLUMN Example: Display temperature reading 2 on row 2 column 8 21/2/8 |
|
Command 22: Temperature reading 2 temperature sensor Basically, you can say temperature reading 2 get the temperature from temperature sensor 5. Run the discover 1wire devices command which stores the addresses in eeprom. This way you can choose which temperatures you want to display on the LCD. Syntax: COMMAND/SENSOR_NUMBER Example: temperature reading 2 use temperature sensor 5 22/5 |
|
Command 23: Display temperature reading 2 on the LCD Syntax: COMMAND/DISPLAY_TEMPERATURE_READING_2 Example: Don't display temperature reading 2 on the LCD 23/0 (to display it use 23/1) |
|
Command 24: Column & Row to display temperature reading 3 *note that any of the temperature readings can be assigned to whatever temperature sensor you want. Syntax: COMMAND/ROW/COLUMN Example: Display temperature reading 3 on row 2 column 8 24/2/8 |
|
Command 25: Temperature reading 3 temperature sensor Basically, you can say temperature reading 3 get the temperature from temperature sensor 5. Run the discover 1wire devices command which stores the addresses in eeprom. This way you can choose which temperatures you want to display on the LCD. Syntax: COMMAND/SENSOR_NUMBER Example: temperature reading 3 use temperature sensor 5 25/5 |
|
Command 26: Display temperature reading 3 on the LCD Syntax: COMMAND/DISPLAY_TEMPERATURE_READING_3 Example: Don't display temperature reading 3 on the LCD 26/0 (to display it use 26/1) |
|
Command 28: Print pH value for pin Syntax: COMMAND/PIN Example: get pH for pin 2 28/2 |
|
Command 29: Column & Row to display pH on LCD Syntax: COMMAND/ROW/COLUMN Example: display pH on row 2, column 6 29/2/6 |
|
Command 30: Print pH value to LCD *note the this measurement is taken from the sketch. If you want to change which pin you're pH circuit is hooked up to change #define PH_PIN at the top of the MacroDuino sketch.Syntax: Syntax: COMMAND/PRINT_PH_VALUE_TO_LCD Example: print pH reading to LCD 30/1 |
|
Command 31: List macro # Since there are 400 bytes worth of macros you can only view settings of 1 macro at a time. Syntax: COMMAND/MACRO_NUMBER Example: List Macro #0 32/0 The return data is json. First number is the macro number (used in the webapp). Second number (after comma) is whether it's enabled. Third number is macro type. The macro type will give you a clue as to what the 4 - 10 numbers are. Simply take a look at how the macro is configure in the documentation and you can figure out what the settings are. This command is used in the web app to list out all the macros and parse what they actually do. |
|
Command 32: Delete Macro # Syntax: COMMAND/MACRO_NUMBER_TO_DELETE Example: Delete macro 0 32/0 |
|
Comand 35: Set IP Address Syntax: COMMAND/IP_FIRST_OCTET/IP_SECOND_OCTET/IP_THIRD_OCTET/IP_FOURTH_OCTET Example: Set IP address to 192.168.1.102 35/192/168/1/102 |
|
Comand 36: Set Subnet Address Syntax: COMMAND/SUBNET_FIRST_OCTET/SUBNET_SECOND_OCTET/SUBNET_THIRD_OCTET/SUBNET_FOURTH_OCTET Example: Set Subnet address to 255.255.255.0 36/255/255/255/0 |
|
Comand 37: Set Gateway Address Syntax: COMMAND/GATEWAY_FIRST_OCTET/GATEWAY_SECOND_OCTET/GATEWAY_THIRD_OCTET/GATEWAY_FOURTH_OCTET Example: Set Gateway address to 192.168.1.1 35/192/168/1/1 |
Comments
I can't download the code...
Sorry about that. Got the
Sorry about that. Got the link mixed up again. It should work now.
Really great site, I really
Can you still ramp up and
Not with the current code,
Not with the current code, but that is going to be added back in.
Updated the code to do 1 hour
Updated the code to do 1 hour fades with the macro. Set type to 2. Minute on and minute off should both be 0 so that means you can only do fades starting at the top of the hour.
Some suggestions: - Allow for
I was hoping nobody would
I was hoping nobody would catch the F and C lol. That's in my todo list.
I like the max and min value ideas. I just had an idea that you you could set any of the macros to automatically log the min and max values during the configuration stage.
European people always are
LOL, and in Canada I use both
LOL, and in Canada I use both depending on the application.
The buttons don't seem to
That's right. You need a
That's right. You need a webkit based browser to be able to use the app on your computer (Chrome, Safari, etc.). It will work great on android and iphones.
Im interested in how you
Not sure what you mean by
Not sure what you mean by that? I haven't used VB in this project.
Hi Andrew, I have a DS18B20,
Hi Andrew,
I have a DS18B20, why does the debug return this?
CRC is not valid! Device is not a DS18S20 family device. jsonp555-5555075({VALUE:{SENSOR:0,VALUE:3210}}) Hardware: Duemilanove ds1307 pin 4 and 5 ds18b20 pin 0 I have no port expander, and it will not recognise the 18b20 on the onewire pin. Thanks, ScottI believe that's because the
I believe that's because the 1wire pin is pin 2.
This is great! I'm new at the
This is great!
I'm new at the arduino but have a Mega2560 and Ethernetshield. My goal is do home automotion. It's a Dutch project called Nodo. But before I start I want to learn something. Can you help me? I would like to have the code and webapp to turn on and off the LED with the webapp.
But how to get the code?
Hi, i got a problem i'm
Hi, i got a problem i'm trying to program a Arduino Ethernet, but i can't connect with it... i'm using Arduino 1.0, some people say the Arduino 1.0 find the IP of Ethernet board and put in Tools>Serial Port> IP xxx.xxx.xxx or something like that,to connect but that dont happen with me... i already test ping by DOS and its ok... Someone can give me a help, what i can do or what i'm doing wrong? Model: Arduino Ethernet http://arduino.cc/en/Main/ArduinoBoardEthernet OS: Windows 7 Compiler: Arduino 1.0
@Albert, You can find the
@Albert, You can find the macroduino code here: https://github.com/practicalmaker/MacroDuino
@chicomoura, I'm not exactly sure what your problem is because I don't use the Arduino Ethernet board.
Hi Andrew,
I just renamed the Pachube
Thanks Andrew; I'll keep an
You should check out the
Sweet videos; very well laid
The ethernet port on the
Seems I forgot to put the
Great work Andrew :) thx
I just saw that. There was a
Hello. This is exactly what I
Good catch. I've updated the
Hello again Andrew.
Hello again Andrew.
Now the code compiles when I uncomment #define CELSIUS, but I'm still getting the values only in fahrenheit in Cosm.
One more thing. This is not a problem for me yet but something I noticed, that made me scratch my head for a few minutes.
When I use four DS18B20 sensors connected to PIN 2 and the COSM_UPDATE_INTERVAL is 10000 the values are all being sent to Cosm and everything works.
But when I change the COSM_UPTDATE_INTERVAL to 15000 or more I only get the values from sensors A & B and the data stream for sensors C & D freezes.
Cheers,
lj
I'll have to play around with
will this work with any of
As long as they're compatible
Hi Andrew,
ok...i need another macro to
Hi,
In the serial monitor type
Using chrome's developer
Humm, it's been awhile since
Hi. I've been using the
Hi. I've been using the macroduino with cosm.com for a few months now and it is working perfectly. So far I've only been measuring temperature with the DS18B20 sensors. Now I'm trying to set up a water flow sensor as well. I've gotten the flow sensors values to the arduino, and it is working great on an individual code. But I'm no sure how I can implement this with the macroduino code. The sensor is a hall sensor sending pulses to a digital pin on the arduino.
Do you have any suggestions how I could get this working and sending the values to cosm? :)
Cheers. LJ
Hey LJ,
Add new comment