Close

Dealing with long i2c transaction and Web controller

A project log for Internet controllable LED message marquee

led marquee controlled with two arduino, and an ethernet shield

XylitolXylitol 09/10/2017 at 17:020 Comments

I came across several problems with the original plan of developement for the web controller and also found a bug in my arduino sketch.
I got the surprise that arduino can't sent over 32 bytes via i2c, in fact you can do way more by upping the buffer size values in the following files.

twi.h:

#define TWI_BUFFER_LENGTH 64

 Wire.h:

#define BUFFER_LENGTH 64

This is a terrible idea and you shouldn't do it, as for those chips there is a limit of 64 in the i2c buffer, sram would be a lot impacted causing arduino to freeze. So, how to do it.. I had a lot of trouble in the logic but the idea is to split the message and construct it on the slave.


I did an example on 2 dummy arduino to debug it more easily, then implemented the final code in my project. My approach isn't ideal but now i did something up to 59 chars. I take the string then split it in two and send the two part separatly over i2c. During that time the receiver continue to assemble till it reach the end. I've added a delimiter '^' at the end that will tell receiver that this is the end of command.
This solved the issue and small strings now also display fine without having to change the array property each time, i just put an array of 60 and auto-pad it with space to reach that length (and to avoid also the hideous auto-zero padding)

Now regarding the web controller part: i was wrong about thinking this project would fit entirely with SQLite. I can use SQLite to store and fetch messages. but for admin authentication and other admin functionality, SQLite will be not a good option, so i'm back with MySQL.. be scared :o)

There still some work to do on the web controler but i will reach the end soon, i do not have time during the week and that i2c thing took me the whole weekend to resolve. So right now i'm gonna update the files on the file manager and continue to work on the web controller for 2,3 hours.

Hopefully next weekend devlog will be about the web controller release.

Discussions