Open wilba84 opened 3 years ago
How does this look for wiring? struggling to find diagrams for this combination of modules.
I think the wiring for the camera itself may be incorrect and suit a arduino uno. Is there suppose to be any wires that the modules have in common?
I tried the wiring above with the ftp demo, SIM7000E and library v1.0.1.
It connected to my ftp server fine, and got upto "initializing SD card" then failed.
Im sure its more of a wiring issue at this stage
This wiring seems to work well and im able to take a photo and save it to the SD card using the "ArduCAM_Mini_2MP_Plus_Multi_Capture2SD" sketch from the Arducam library.
I have a photo on the SD Card called "1.jpg" that im trying to modify the FTP Demo sketch to send to my FTP server.
Here is the sketch
include "Adafruit_FONA.h"
include
include
File myFile; const int CS_pin = 53;
define SIMCOM_7000 // SIM7000
define FONA_PWRKEY 12
/* FTP SETTINGS *****/
define` serverIP "101.190.192.206" // Use global IP for remote connection
define serverPort 21
define` username "Will"
define password "will"
HardwareSerial *fonaSerial = &Serial1; Adafruit_FONA_LTE fona = Adafruit_FONA_LTE();
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0); uint8_t type; char imei[16] = {0}; // MUST use a 16 character buffer for IMEI!
void setup() { Serial.begin(115200); Serial.println(F(" FTP Example ")); pinMode(FONA_PWRKEY, OUTPUT); powerOn(); // Power on the module moduleSetup(); // Establishes first-time serial comm and prints IMEI
// Set modem to full functionality fona.setFunctionality(1); // AT+CFUN=1 fona.setNetworkSettings(F("telstra.internet")); // For Telstra (Australia) SIM card - CAT-M1 (Band 28) fona.setPreferredMode(38);
// Connect to cell network and verify connection // If unsuccessful, keep retrying every 2s until a connection is made while (!netStatus()) { Serial.println(F("Failed to connect to cell network, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Connected to cell network!"));
// Disable data connection before attempting to connect fona.enableGPRS(false);
// Turn on data connection while (!fona.enableGPRS(true)) { Serial.println(F("Failed to enable data, retrying...")); delay(2000); } Serial.println(F("Enabled data!")); / // Connect to FTP server Serial.println(F("Connecting to FTP server...")); while (!fona.FTP_Connect(serverIP, serverPort, username, password)) { Serial.println(F("Failed to connect to FTP server!")); delay(2000); } / // Initialize SD card Serial.print(F("Initializing SD card... "));
if (!SD.begin(CS_pin)) { Serial.println(F("failed!")); while (1); } Serial.println(F("done!"));
// Connect to FTP server Serial.println(F("Connecting to FTP server...")); while (!fona.FTP_Connect(serverIP, serverPort, username, password)) { Serial.println(F("Failed to connect to FTP server!")); delay(2000); } / // Let's rename the file we just uploaded! Serial.println(F("Renaming file on FTP server...")); if (!fona.FTP_Rename("/", "upload.txt", "newFile.txt")) { // Path, old name, new name Serial.println(F("Failed to change file name!")); } / // Now the really cool part! We're going to upload // a picture to the server using the extended PUT // method (auto-detected inside the FTP_PUT method // based on the content size // NOTE: Haven't tested extended PUT method yet because // SIM7000G firmware does not support it for some reason...
size_t fileSize; char * uploadContent = readFromFile("1.jpg", &fileSize);
Serial.print("File size: "); Serial.print(fileSize); Serial.println(F(" bytes"));
// Upload picture via FTP if (!fona.FTP_PUT("1.jpg", "/", uploadContent, fileSize)) { // File name, file path, content, content length Serial.println(F("Failed to upload!")); }
// Close FTP connection // Note that with FTP GET/PUT requests, connection to FTP server is automatically // closed after the request is successfully completed so the following function // might give an error. if (!fona.FTP_Quit()) { Serial.println(F("Failed to close FTP connection!")); } }
void loop() {
}
// Power on the module void powerOn() { digitalWrite(FONA_PWRKEY, LOW); // See spec sheets for your particular module
if defined(SIMCOM_2G)
delay(1050);
elif defined(SIMCOM_3G)
delay(180); // For SIM5320
elif defined(SIMCOM_7000)
delay(100); // For SIM7000
elif defined(SIMCOM_7500)
delay(500); // For SIM7500
endif
digitalWrite(FONA_PWRKEY, HIGH); }
void moduleSetup() { fonaSerial->begin(115200); // Default LTE shield baud rate fona.begin(fonaSerial); // Don't use if statement because an OK reply could be sent incorrectly at 115200 baud if (!fona.begin(fonaSerial)) { Serial.println(F("Couldn't find modem")); while(1); // Don't proceed if it couldn't find the device }
type = fona.type(); Serial.println(F("FONA is OK")); Serial.print(F("Found ")); switch (type) { case SIM7000E: Serial.println(F("SIM7000E (European)")); break; }
// Print module IMEI number. uint8_t imeiLen = fona.getIMEI(imei); if (imeiLen > 0) { Serial.print("Module IMEI: "); Serial.println(imei); }
// Needed for rare cases in which firmware on SIM7000 sets CFUN to 0 on start-up fona.setFunctionality(1); // Enable cellular (RF) with AT+CFUN=1 }
bool netStatus() { int n = fona.getNetworkStatus();
Serial.print(F("Network status ")); Serial.print(n); Serial.print(F(": ")); if (n == 0) Serial.println(F("Not registered")); if (n == 1) Serial.println(F("Registered (home)")); if (n == 2) Serial.println(F("Not registered (searching)")); if (n == 3) Serial.println(F("Denied")); if (n == 4) Serial.println(F("Unknown")); if (n == 5) Serial.println(F("Registered roaming"));
if (!(n == 1 || n == 5)) return false; else return true; }
// Write to a file in the SD card bool writeToFile(const char fileName, char * content) { myFile = SD.open(fileName, FILE_WRITE);
// If the file opened successfully, write to it if (myFile) { Serial.print("Writing to file..."); myFile.println(content); // Write the desired content onto the file myFile.close(); // Close the file Serial.println(" done!"); } else { Serial.println("Error opening file!"); return false; }
return true; }
// Read the contents of a file in the SD card char readFromFile(const char fileName, size_t * fileSize) { char contentBuff[250];
myFile = SD.open(fileName); *fileSize = myFile.size();
if (myFile) { // Read from the file until there's nothing else in it while (myFile.available()) { strcat(contentBuff, myFile.read()); } myFile.close(); // Close the file; only 1 can be open at a time } else { Serial.println("Error opening file!"); }
return contentBuff; }
Here is the serial
I have the whole sketch working now apart from the image upload part. Serial freezes on line: " char * uploadContent = readFromFile("1.jpg", &fileSize);"
size_t fileSize; char * uploadContent = readFromFile("1.jpg", &fileSize); Serial.print("File size: "); Serial.print(fileSize); Serial.println(F(" bytes"));
// Upload picture via FTP if (!fona.FTP_PUT("1.jpg", "/", uploadContent, fileSize)) { // File name, file path, content, content length Serial.println(F("Failed to upload!"));
Looking at "readFromFile", it freezes on " myFile = SD.open(fileName);"
// Read the contents of a file in the SD card char readFromFile(const char fileName, size_t fileSize) { char contentBuff[1000]; myFile = SD.open(fileName); fileSize = myFile.size(); if (myFile) { // Read from the file until there's nothing else in it while (myFile.available()) { strcat(contentBuff, myFile.read()); } myFile.close(); // Close the file; only 1 can be open at a time } else { Serial.println("Error opening file!"); } return contentBuff; }
Is it (fileName) that is causing the issue. I couldnt find where/how it gets the fileName value. I tried changing the fileName part of SD.open, If i change it to 1.jpg I get the same result. If i change it to test.txt It fails to read but gets further along in serial
Hi, I am following the tutorial for using FTP to upload a image from arducam. There is no guide for wiring the camera side of things, I cant how the button to take the photo is supposed to be wired and theres no library/code for the camera in the example. Cheers Will