I’m using the uCAM III from 4D Systems on a Particle Electron. The end goal is to take two pictures a day, and upload them to a webserver, For the time being though, I have limited my efforts to just taking a picture locally and sending it over serial.
I use this Arduino library. Note that although it is designed for the uCAM II, there is backward compatibility so whatever code works on the II should also work on the III. Please note that my understanding of electronics and coding is pretty limited; I made an attempt with running this library in the Particle IDE, and found that the #include ‘SoftwareSerial.h’’ in the .h file is invalid with Particle products.
However, I could use some guidance on how to proceed from here. A lot of the commands in the .cpp and .h files are serial commands, and my understanding of things is too limited to really know how to mitigate this after taking the #include SoftwareSerial.h out
I have written a ParticleSoftSerial library that should be able to substitute Arduino's SoftwareSerial for baud rates up to about 38400. With one of the latest features added in 0.8.0 to reduce interrupt latency even 57600 should and 115200 may be possible (when I get time to incorporate that).
Since this library is interrupt driven, you are limited to pins that are interrupt enabled and available for RX.
But having said that, SoftwareSerial is mainly meant to be used when there is no (free) HW serial interface. If you have, use that. It's just that much more reliable - especially at higher baud rates.
So by including ScruffR’s library, the .cpp and .h files compile just fine now. Not sure if it actually works or not, but at least it compiles.
Now to set up a test .ino file…
This is what I have at the moment: https:/go.particle.io/shared_apps/5aa18db9a96412101b000016
Right now it’s outputting some compiling errors (UCAMII, camera, stateTime and mySerial don’t name a type)
@ScruffR He switched the Arduino example code that used Arduino’s SoftwareSerial to the ParticleSoftSerial which did get the library to compile.
But what you recommended is to skip using the SoftwareSerial completely if you have an extra hardware serial port available because it’s more reliable.
Since the Electron has 2 UART ports he should be able to skip using the SoftwareSerial library and go for the more reliable hardware serial port correct?
I don’t have any free time to sit down and mess with this and I don’t have the camera but if you have some free time could you take a look at the latest code he shared and let us know what you think is best for trying to get it to work on the Electron?
@Vitesze Have you tried this library from last year that says it’s working with the camera module + Photon to see if it runs fine?
Yes I included the ParticleSoftSerial requirement and replaced SoftwareSerial commands with ParticleSoftSerial commands. Thanks for all the help, not sure how I can make it worth everyone’s time, but whatever comes out of this project I will publish it on the forum afterwards as I think it’d be a very interesting application for the Electron.
I have briefly looked through that library, but I will work on it some more now
I don't think you need the software serial library at all and can go for the more reliable hardware serial on the Electron. Need ScruffR's advice on that though.
I don't see any reason this can't work the way we're wanting it to though, just will take some time to work through all this.
@Vitesze I had a chance to take a look at that uCam2 library that was supposed to work on the Photon.
I altered this library removings parts that we don’t need for now.
The code will attempt to take a snapshot and then a full picture when you pull pin D1 high to 3.3v so try that and watch what the serial output says about successfully taking the picture or not.
If it says it successfully takes the picture then we will need to change the code where attempts to send the picture data to a IP address so it does what we want it to do.
I have written a completely new uCamIII library which should also support uCamII (just some advanced functions aren’t supported by the II).
One major difference to the Arduino uCamII library is that mine is not tied to any serial interface but can be used with any of the HW interfaces andParticleSoftSerial too.
If you could try the uCamII and the Webserver example on a Photon, I’m open to suggestions how to improve it.
Electrons can’t easily be used as Webservers (due to “non-routable” local IP), so currently on Electrons the demo can only stream the taken image to USB Serial where you need to dump the stream into a file (or any other sink) to further process it.
Next step will be a TCP transfer sample that can also be used to receive the data wirelessly from an Electron.
I received the camera also and its images are good enough to be useful.
I’ll give your code a try on the Photon.
What I’m wondering is if we could store the picture data on an Electron in a variable array instead of pushing it to a SD card for storage. Even if there is enough room to store only 1 picture that would be fine, I know memory is limited.
Then we could use @rickkas7 FTP library to upload that picture data array to an FTP server which I know works because I’ve tested it in the past with success.
I had a look at @rickkas7's FTP endeavour but his assertion about FTP being a "bitchy" protocol with lots of overhead, made me decide to rather go for a simpler demo more along his line of this
or any other TCPClient -> node server route.
My sample just stuffs the image in a static array of 160x120x2 = 38400 byte (max size for raw images produced by uCamIII - even 640x480 JPG won't be as big as that).
But with bigger projects that might not be the way to go.
Really nice that this can be setup and you can just call the function remotely to have the picture taken and displayed on a local browser.
Less overhead on the Electron would be ideal, although I’m not sure how much overhead we would be talking when just uploading these images using his FTP library.
Looking forward to trying your Electron sample program