View previous topic :: View next topic |
Author |
Message |
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Thu Mar 03, 2016 5:39 pm Post subject: Sending a LinkSprite jpeg File as MMS Using a SIM5216A |
|
|
This program instructs a LinkSprite color camera to take a picture and send the resulting jpeg file to a ITREAD 3G SIM5216A GSM. The SIM module is then instructed to send the picture to mobile phone and/or email address as a MMS file. The program also provides for sending text messages using either SMS or MMS.
The electronic design uses one of the four hardware UARTs of an ATMega2560 to communicate with the SIM and LinkSprite camera. The UARTs of the three devices are connected in a loop (i.e. ATmega to the SIM, SIM to the LinkSprite and LinkSprite back to the ATMega). Located in each of the three legs of this loop is a tri-state gated buffer/driver (parts of a SN74HS125). When a buffer is disabled (by a high OE signal) its output transistor is turned off which blocks data flow and presents a high impedance state to the data line.
The process for taking the picture and sending it out via the SIM as an MMS file is the following:
1. Enables the ATmega/Camera link and gives the LinkSprite camera the instruction to take a picture. This link is then disabled.
2, Enables the ATmega/SIM link and gives the instructions necessary to prepare for the transmission of an MMS message. This link is then disabled.
3. Enables the ATmega/Camera link and instructs the camera to start downloading the jpeg file in one batch. After the passage of some unwanted data the Camera/SIM link is enabled and data then flows to the SIM. This link is disabled after the detection of the "end-of-file" data (FF D9) to again block unwanted data. The ATMega/Camera link is then disabled.
4. Enables the ATMega/SIM link and sends the final instructions to the SIM necessary to send the jpeg file to the mobile service provider.
My previous posting that made use of the SIM900 includes printouts from my logic analyzer that shows the timing of these steps. My analyzer is not working at this time so I can't update up date these files.
The original project used a 2G SIM900 module that ran with a ATMega168. For this version I have used a ATMega2560 because for planned additions I will need more I/O pins. However as presented here it could still run with the single hardware UART of the ATMega168.
I suggest that one first get this program up and running by sending the jpeg file to a smart phone. I find for my case when sending the file to an email address it often got delayed or lost. If I learn more about this I will post an update.
Note the ITEAD shield as an error in its silk screen printing in that the identification of "5v" and "3v3" pins is reversed. This may have be corrected in later issues.
For my SIM900 posting I had two unresolved issues. I could not send the largest size LinkSprite image (640*480) and the picture could not be viewed by Windows Photo Viewer. Both of these issues seem to resolved through no effort of my own.
Please few free to contact me if you have questions. My email address is in the attached program listing and on the attached electrical schematic. |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Thu Mar 03, 2016 11:19 pm Post subject: LinkSprite/SIM5216A files |
|
|
The attached zip file contains the BASCOM program and a pdf file of the electrical schematic. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Mar 04, 2016 9:59 am Post subject: |
|
|
Thank you for sharing this useful example.
I could not read the cad file. i guess it requires special software. it would be convenient to include jpg or png. _________________ Mark |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Fri Mar 04, 2016 12:49 pm Post subject: Schematic as PDF |
|
|
Mark, I made a mistake in making up the zip folder. I should have included a pdf file in a zip file which is now attached.
My plans for this program are to add the following
WDT protection
a DS3232 RTC
Temperature, relative humidity and barometric pressure monitoring
From this the calculation of the absolute humidity
a Sonic range finder to measure tank level
The ability to operate relays remotely
This all needs to be done by early in June.
I may not post these efforts as they are simply the inclusion of programming I have already provided elsewhere on the forum.
I also have PCB designs in ExpressPCB software if anyone is interested. I do not have Eagle files.
Alan |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Mar 04, 2016 8:48 pm Post subject: |
|
|
Thanks for the update. This is much better. Good thing that circuits are international. Only resistor symbol differs, but it remind me to good old radio shack cook books.
While the complete project is interesting, the code as is , is simple and understandable. _________________ Mark |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Thu Oct 20, 2016 8:26 pm Post subject: LinkSprite SIM5216A Update Using an ATMega168 |
|
|
I previously posted this SIM5216A project using an ATMega 2560. I have decided that it will work best for me to have one printed circuit board (PCB) running a ATMega168 that only sends SMS messages and MMS messages and pictures and leave additional software and hardware development to a separate PCB running a larger chip (probably an AtMega1284)that will have more I/O capability. The two will communicate through an I2C interface.
Also in my earlier posting I did not implemented the LinkSprite 2MP camera. I have added this to this update as the 2MP camera has a default baud rate of 115200 which is the same as the SIM5216A. To further simplify the program I have removed the ability to interface with other LinkSprite cameras.
The attached pdf includes a circuit diagram. I have not included the results of running my logic analyzer as they are much the same as posted before.
I do have one unresolved issue that does not impact the running of the program. It involves use of an external clock running at 14.7456 MHz. It is discussed in the downloaded program listing at the end of the introduction. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Oct 27, 2016 3:39 pm Post subject: |
|
|
thanks for sharing the update.
about the problem, did you try if normal sending works with that external osc?
and did you measure the actual baud for the soft uart?
maybe it is off too much?
i see no reason why it would work different. _________________ Mark |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Thu Oct 27, 2016 4:42 pm Post subject: Baud Rate |
|
|
Mark:
I will try those two ideas although the reason for using the 14.7456 MHz oscillator is that it should have zero error for any baud rate.
Alan |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Oct 27, 2016 7:25 pm Post subject: |
|
|
yes but the software UART has calculated bit rate. But normally, the higher the clock, the better the result. _________________ Mark |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Wed Nov 29, 2017 1:14 am Post subject: Spinel and LinkSprite Serial jpeg Cameras |
|
|
I have continued to expand this project but didn’t plan to post any more updates as I didn’t believe they would be that useful to BASCOM Forum members. However, recently the makers of Spinel cameras (they make the cameras marketed as “LinkSprite”) have made a software change that requires a change to part of my previously submitted program.
When the Spinel cameras download a jpeg file there are leading bytes before the jpeg image marker “FF D8” and also after the “FF D9” trailer at the end. To view the jpeg file in Windows Photo Viewer it is necessary to block these bytes. In earlier versions of the cameras there was a time gap between the leading non-jpeg bytes and the “FF D8”. I found that the transmittal of the last of the non-jpeg leading bytes was completed 2.5 ms after start of the request for download and “FF D8” started at about 12 ms. So, to block the bytes I imposed a 6 ms delay before enabling of the camera-to-SIM link.
In the newer Spinel SC20MPC camera the leading gap has been removed. I contacted Spinel tech support and they replied this was intentional. For the newer cameras my program will not work because it will block the “FF D9” and some bytes that follow. So, I have made changes to the “Download_Picture” subroutine. My program now works with the SC20MPC camera but the downloaded jpeg file cannot be viewed using Windows Photo Viewer because of the leading non-jpeg bytes. It can be viewed by XnView.
Rather than download my revised, but somewhat large 1900 line program, I thought for the forum it would be useful to write a small program that only deals with interfacing with the Spinel cameras. That file is attached. Later I my download a second program that adds the SIM5216A aspect that allows for connection to wireless service provider.
The SPC20MPC is a big improvement over the older cameras in that it has automatic exposure, white balance and gain control. I now buy the cameras only from Spinel at https://jpegcamera.com/.
Mark, you might look at lines 31, 40 and 43 of the attached file. The variables dimensioned do not represent dead code as the italics would indicate. Also, where is the option to turn off dead and excluded code? Search leads one to “This option turns on/off marking of dead code” but where is this option? I don’t find it in “options” or elsewhere. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Wed Nov 29, 2017 10:16 pm Post subject: |
|
|
Code options are under the EDIT menu so you can turn them on/off quickly
Dead code shows JPEG array which is not referenced. And Temp_byte2
At least not in the sample you sent.
also : add a space between PRINT and # otherwise you get a lot of errors in the future.
Print #1 'OK
Print#1 'not ok _________________ Mark |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Thu Dec 14, 2017 4:52 pm Post subject: |
|
|
The attached BASOM file, “SIM5216A_Spinel forum” updates my ATmega1284 program so that it will take pictures using the highest resolution the Spinel camera provides, 1600 x 1200. In this regard there are errors in the Spinel manual “SC20MPC: 2 Mega Pixels Serial JPEG Camera User Manual”, Rev D. Command Protocol 3, “Read Image Data Length” does not acknowledge that the larger images require three bytes to read the data length. Similarly, for Protocol 4, “Read Image Date (sic)” one needs three bytes each to define the start and stop file locations. The attached file show how to do this.
Also attached are the following;
1. The BASCOM program for the ATtiny861A “ping_slave_ATtiny861A forum” that provides input to the ATmega1284. The ATtiny861A acts a I2C slave to the ATmega1284 using the BASCOM add on I2C-slave library.
2. Electrical schematics for both the ATmega and ATtiny projects.
3. A pdf file that includes; 1) pictures of the two projects, 2) screen shots of output from the ATmega project (the “Print #1” statements) to a ASUS tablet computer running RealTerm, and 3) one picture of my shop taken by a Spinel SC20MPC camera at 640x480. It is interesting that I see no difference between a 640X480 image and any one of the higher resolution images. I have asked Spinel about this.
4. Files created by my Saleae logic analyzer of the input to the Spinel camera for a 1600x1200 image and the responses received from the camera. You will need a Saleae logic analyzer to view this file. The Saleae analyzer is a good logic analyzer at a reasonable price. My only complaint is that it will only display a black background so it is poor for printing the captured data.
5. Files for the PCB designs use ExpressPCB software. The software to read and modify these designs is available free from www.expresspcb.com/. Let me know if you would like files for other PCBs or need help obtaining the PCBs from expressPCB.
Feel free to contact me if you have questions. You will find my email address in the “SIM5216A….” file around line 318.
I am not entirely happy with the Spinel camera. You will notice in the attached image the front of the shop shows well but any detail to the sides of the shop is lost. If Spinel comes out with something new I will try it. If you know of another serial jpeg camera let me know and maybe I will work with it.
Alan Hosler |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Dec 15, 2017 11:38 am Post subject: |
|
|
Hello Alan
Thank you for the update and all the details. This is a good demo of a real world application that uses a slave processor using I2C.
The camera pictures have very good quality. At least, for me it would be good enough.
I have worked with gsm modems too but never explorer the options you use.
Thanks for taking the time to document and sharing ! _________________ Mark |
|
Back to top |
|
|
|