Show Posts
Pages: 1 ... 5 6 [7] 8 9 ... 30
91  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 16, 2014, 06:14:18 pm
Some news on the latest development in Cosa.

1. ThingSpeak Channel and TalkBack example sketch
An example sketch that allows the TalkBack commands LED_ON/OFF, SENSOR_ON/OFF, PING/PONG together with post of sensor data to a channel. The command SENSOR_ON will enable post of sensor data (DHT11) to a channel. The command LED_ON/OFF controls a led. Last the command PING demonstrates issuing commands back to the server (PONG).

2. Alarm class
Scheduling functions with seconds level resolution. The callback member function may be called once or periodic. Typical usage is "call function at given time", "call function every hour", etc.

3. Activity class
High level scheduling of functions with start time, duration and period on seconds and minutes level of resolution. The callback member function is periodically called throughout the activity duration. May be used to schedule activities such as "during 10:00 to 14:00 sample sensor every 5 seconds" or "every hour sample sensors every 10 seconds for two minutes", etc.

4. Nucleo (multi-tasking) updates
a. Improved delay handing
The thread level delay function is now based on a delay queue.
b. Performance optimization
The context switch is 11 us, semaphore wait-signal pair is 41 us.
c. Message Passing (Actors)
d. Blink example with threads
Three threads running on an ATtiny85 with 32 bytes stack and 33 byte context per thread. Demonstrates low power when using Cosa Nucleo.

5. Sizeof Benchmark update
List of classes in Cosa and size of instances. Note: static data not included.

6. Cosa example sketches
The example sketch folders have been restructured. There are over 130 test, benchmarking and example sketches in total.
And most of them may be compiled for Tiny, Standard, USB, Mega, Mighty Arduino based boards.

92  International / Fran├žais / Re: programmation avec arduino atmega 1280 on: March 16, 2014, 11:08:08 am

93  Using Arduino / Project Guidance / Re: External Interrupt for MEGA 2560 with SQW from DS1307 on: March 15, 2014, 12:05:49 pm
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68

volatile int count;

void setup()
  attachInterrupt(0, compteur , RISING);

void compteur()
  count = count + 1;

void loop()
  int c = count;
  while (c == count);
94  Using Arduino / Project Guidance / Re: Counting length of pulses on: March 13, 2014, 02:12:23 am
Im doing a school project and you guys on here are my only hope  smiley-confuse

I will have an input from another microcontroller and i need to count the length of pulses,
there will be 3 different pulses one after another.

So, basically there will be one pulse for lets say 21 seconds, i need to store this,
then 5 seconds or so after that pulse has finished another will start on the same pin for lets say 15 seconds, i need to store this separately,
finally 5 seconds after the previous pulse there will be one last pulse for 3 seconds and i need to store this separately from the other 2 pulses,
What have you learnt in school? What type of problem is this? Do you know what a finite state machine is? And how it can be programmed? Is the signal stable? What is the distance, length of the cable? Is there noise? How do you indent to connect the two microcontrollers? Does the solution have to be low power? Will the microcontrollers run on battery? Are there programming languages for this type of problem?

95  Development / Other Software Development / Re: Writing menu library, need help with #include's on: March 10, 2014, 06:07:30 pm
What is the compiler trying to tell you? It points to the line;

If you define lcd as a local variable in the constructor M16 it is not available after that. It is created on the stack and then removed after the constructor (M16).

"I guess I have to declare lcd somewhere else?" yepp.

96  Using Arduino / Networking, Protocols, and Devices / Re: SNMP Manager example code on: March 09, 2014, 05:59:30 am
Yes it is possible to write that. It is not implemented in that library,

But why not write it as an uint8_t vector instead.

97  Using Arduino / Networking, Protocols, and Devices / Re: SNMP Manager example code on: March 09, 2014, 04:11:43 am
What library are you using? Your code above is wrong as the OID is a string and you are accessing characters and not numbers. Cheers!
98  Using Arduino / Networking, Protocols, and Devices / Re: SNMP Manager example code on: March 08, 2014, 07:26:11 pm
The OID encoding of 247 is; 128+1,247-128=129,119. Which is what you got.

The full OID should be encoded as 1,3,6,1,4,1,129,119,87,0. This should be prefixed with the length of the OID which is 10.

BTW: is an enterprise OID for AEG Electrocom.

99  Using Arduino / Sensors / Re: Real Time Clock DS1307 and Libraries on: March 08, 2014, 04:46:02 pm
Page 8 in the Product Description for DS1307 ( might be of help. The problem is the library that adjusts the year. The chip handles 00-99 year value (in BCD). The library adjusts to 20XX.

Depending on what you are looking for you will have to at least have to modify the library, find another library or write your own.

100  Development / Other Software Development / Re: Changing the CPU clock in real time (run-time), to save some battery power on: March 08, 2014, 04:12:36 pm
This was an interesting approach. I have done some work with Cosa to get low power built-in but only used the power attributes. Below is a sketch I wrote to demonstrate different low power tweaks.
#include "Cosa/Event.hh"
#include "Cosa/Pins.hh"
#include "Cosa/Power.hh"
#include "Cosa/ExternalInterrupt.hh"
#include "Cosa/Watchdog.hh"


OutputPin led(Board::LED);

class Button : public ExternalInterrupt {
  OutputPin* m_led;
  Button(Board::ExternalInterruptPin pin, OutputPin* led) :
    ExternalInterrupt(pin, ExternalInterrupt::ON_LOW_LEVEL_MODE, true),

  virtual void on_interrupt(uint16_t arg = 0)
    if (m_led != NULL) m_led->on();
    Event::push(Event::NULL_TYPE, NULL);

Button wakeup(Board::EXT0, &led);

void setup()
  // 0 uA, already done by startup
  ACSR = _BV(ACD);
  ADCSRA = 0; 
  UCSR0B = 0;
#if defined(USE_DISABLE_PINS)
  // 2 uA, possible uart pin needed disconnecting
  DDRB = 0b11111111;
  PORTB = 0b00000000;
  DDRC = 0b11111111;
  PORTC = 0b00000000;
  DDRD = 0b11111011;
  PORTD = 0b00000100;

void loop()
  // 180 uA - (BOD + PIN disable = 23 uA)
  Event event;
  Event::queue.await(&event, SLEEP_MODE_PWR_DOWN);
  // 180 uA - (BOD + PIN disable = 23 uA)

  // 1,5 mA, 64 ms blink
  Watchdog::begin(16, SLEEP_MODE_PWR_DOWN);
  while (wakeup.is_low()) {
  // 15 mA, 16 ms blink
  while (wakeup.is_low()) {
    for (uint8_t i = 0; i < 4; i++) DELAY(16000U);

Link to the example sketch:

The results are for Arduino Mini Pro, approx. 3 mA idle, power LED on.
 1. Modifications; removed power LED resistor, 1 Kohm.
 2. Powered via FTDI USB/TTY adapter 5 V
     a. Connected to VCC/GND, 180 uA
     b. Connected to RAW/GND, 840 uA
     c. Connected to VCC/GND, + BOD disabled, 160 uA (See Power.hh)
     4. Connected to VCC/GND, + disable pins, 157 uA
 3. Powered with LiPo 3,7 V
     a. Connected to VCC/GND, 32 uA
     b. Connected to RAW/GND, 840 uA
 And for Arduino Lilypad, 8 Mhz, no modifications
  1. Powered via FTDI USB/TTY adapter 5 V, 18 uA
  2. Powered with LiPo 3,7 V, 16 uA
I have added frequency scaling to Cosa but there are ripple effects to consider before testing. Mainly as you write on timers and ADC.

Cheers! And thanks for the inspiration.
101  Using Arduino / Project Guidance / Re: Change SDA and SCL pins on Mega on: March 08, 2014, 03:15:10 pm
Non-problemo, Then you can have the RTC (DS1307) and SHT21 on the same pins. No extra pins needed!

102  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 08, 2014, 03:09:09 pm
I have seen MQTT-SN implementations for Arduino and RF devices (JeeNode with RFM12B, CC stuff etc), and some of them are pretty small - qos -1 with only a publish function - and some are rather large - taking 20kb space...
Are there any MQTT-SN nodes that you want to communicate with (bridge sensor data through)? If the bridge is also Arduino based it might as well handle protocol translation. This makes the Wireless interface much simpler.  

I hit some issues with the GSM shield and refocused to instead writing a driver for a Wifi module. The idea is to implement the AT based protocol as the Cosa Socket interface.

The latest development is support for the ThingSpeak TalkBack API. Both "Execute next command" and "Add command" have been implemented so it is really easy to handle both receive/dispatch TalkBack command and send commands to the server.

103  Development / Suggestions for the Arduino Project / Re: Improving core Arduino Code for ADC initialization on: March 08, 2014, 02:49:42 pm
Why is the original code better? It uses the correct symbols from AVR and not the bit values.

What could be better in both? Actually it is the enable of the converter. This could be done later on and only when needed. If using a strategy for low power design this is not a very good idea. The Analog Comparator should also be disabled.

I agree that the setting can be written as a single line. There is no need for four sbi(). In the large scale of things this is not very important. A few bytes extra. And a few extra cycles at start up (once).

Below is what you find in Cosa init;
void init()
  // Set analog converter prescale factor and but do not enable conversion
#if F_CPU >= 16000000L
  ADCSRA |= (_BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0));
#elif F_CPU >= 8000000L
  ADCSRA |= (_BV(ADPS2) | _BV(ADPS1)             );
  ADCSRA |= (             _BV(ADPS1) | _BV(ADPS0));
  // Disable analog comparator
  ACSR = _BV(ACD);

  // The bootloader connects pins 0 and 1 to the USART; disconnect them
  // here so they can be used as normal digital IO.
#if defined(UCSRB)
  UCSRB = 0;
#elif defined(UCSR0B)
  UCSR0B = 0;

  // Allow interrupts from here on

  // Attach the USB module and possible CDC/HID
#if defined(USBCON)
What would be even better? I think defining the prescale value from conversion and system clock. PRESCALE = F_CPU / F_ADC. This is what inspired me from this topic.


BTW: I would like to encourage you to make a pull request to the Arduino repository.
104  Using Arduino / Project Guidance / Re: I2c sniffer on: March 08, 2014, 02:17:41 pm
This is not possible with ATmegaXXX processors and the internal TWI/I2C hardware but actually possible with ATtinyXXX or others that have internal USI. The problem has to do with the address matching. In TWI/I2C the slave address match is build-in. On USI this is done in software and you can implement a monitor.

Obviously you could implement this with soft TWI on any Arduino.

105  Using Arduino / Project Guidance / Re: Change SDA and SCL pins on Mega on: March 08, 2014, 02:11:38 pm
DHT11 is not an i2c device, so you could not use that with the rtc. The sht15 is i2c, that should work with your rtc.
Sorry to say this but both these devices, DHT11 and SHT1x, are NOT I2C. They have other protocols.
Pages: 1 ... 5 6 [7] 8 9 ... 30