Sorry, forgot to comment the Spark.function(), I don't use it.
I just flash the core via usb with the code in the particle build page, then I ask for the serial monitor's data with this code:
import binascii
import serial
import sys
from twython import Twython
import os
nf = open("atTheDoor.jpg","wb")
ser = serial.Serial('/dev/cu.usbmodem1411', 9600) # Establish the connection on a specific port
cont = 1;
str_buffer = ""
def tweet():
print("now tweet")
photo = open('atTheDoor.jpg','rb')
api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
api.update_status_with_media(media=photo, status='My spark be tweeting images now => @carlocotto ')
photo.close()
print("donde tweeting")
while 1:
c = ser.read() # Read the newest output from the Arduino
print c
if c == '+':
print('end')
print('yaaa se acabo la foto')
tweet()
break
str_buffer = str_buffer + c
# cada 4 caracteres escribe al archivo de salida
if cont % 4 == 0:
print(str_buffer)
#print (ser.read())
nf.write(binascii.a2b_hex(str_buffer))
# se reinicia el buffer y el contador
str_buffer = ""
cont = 1
else:
cont = cont + 1
Close the file
#nf .close()
I just need the serial port problem fixed, everything else works fine.
It might be /dev/tty.
if i remember correctly. Can you try using a terminal software to see if the device is listed there?
Still having the same problem, when I ask for āparticle serial listā says āno devices available via serialā
ScruffR
September 25, 2015, 3:53pm
64
Have you tried my short test sketch from above?
Yes, and it gave me this error:
so I replaced it for a "HIGH", asked for the serial monitor and still said "no device available via serial"
ScruffR
September 25, 2015, 4:02pm
66
That was a typo, which has been corrected already digitalWrite(D7, !digitalRead(D7));
If this sketch doesnāt work, Iād expect youāve got a problem with your USB port, USB cable or computer and not the Core.
Is there any other way I could see the serial monitor than the command line?
ScruffR
September 25, 2015, 4:26pm
68
Maybe @kennethlimcp can help here since I have no clue about Mac.
But Iāve heard about CoolTerm, if this helps.
bko
September 25, 2015, 4:47pm
69
Hi @KarinaMendez
I use CoolTerm or just the command line tool screen
on my Mac. Both work great. You will have to figure out which device in /dev/ is your Photon. The easiest way is to just list the /dev/ directory before and after connecting it.
http://freeware.the-meiers.org/
http://hints.macworld.com/article.php?story=20061109133825654
I know witch one is it: dev/cu.usbmodem1411, it appears when I ask for the particle serial list before flashing the code, but after flashing any code, thereās no serial ports availableā¦
bko
September 25, 2015, 7:16pm
71
Hi @KarinaMendez
If this is a Core, then the USB device only get enumerated and shows up after your firmware does Serial.begin(baudRate);
.
If this is a Photon, it normally enumerates the device by default.
By the way, the name can change if you plug in other USB devices with serial capability.
Something that happens is that when I set it up with the command line to the cloud, it never passes the step āclaiming core to your accountā.
ScruffR
September 26, 2015, 6:50am
74
bko:
If this is a Core, then the USB device only get enumerated and shows up after your firmware does Serial.begin(baudRate);.
If this is a Photon, it normally enumerates the device by default.
This is what I keep trying to get accross too!
1 Like
By any chance do you have an example of how to post data from spark to a database? Been trying some like
but it's not working