Ewon TechForum
Providing technical solutions to technical requests


eWON and Facebook
simon Offline
eWON Support
#1
Hi Guys,

I have recently created a Facebook page for publishing the data of the Weather Station (connected to eWON) that we have here (https://www.facebook.com/EWON-Weather-Station-1724188781137106/)
This to demonstrate that the eWON is able to post data to Facebook thanks to the graph API.

The eWON creates a new post on the Facebook page every 4 hours. It actually sends some Weather data like the Temperature, Humidity...

Here is my code :



Code:
Rem --- eWON start section: Init Section
ewon_init_section:
Rem --- eWON user (start)
ONDATE 1,"0 */4 * * *","GOTO FACEBOOK"
ONSTATUS "GOTO FACEBOOK_CALLBACK"
END


FACEBOOK:
u$ = "https://graph.facebook.com/v2.6/1724188781137106/feed"

m$ = "POST"

emoticon$ = @GETEMOTICON$()

d$ = 'message=Belgium Weather (Nivelles) : ' + emoticon$
d$ = d$ + '%0A Local Time : ' + TIME$
d$ = d$ + '%0A Temperature : ' + STR$ outTemp@ + ' DegC '
d$ = d$ + '%0A Humidity : ' + STR$ outHumi@ + ' %'
d$ = d$ + '%0A Wind Speed : ' + STR$ avgwind@ + ' km/h'
d$ = d$ + '%0A Atmospheric Pressure : ' + STR$ AbsPress@ + ' hpa'

d$ = d$ + '&access_token=EAAQTts8JDb0BAHYeAZBA6BO0Smva8vQ4OmRK2PPE6Co1ZAbLAqrqG6ZBoZCFAG6lNdaeRTs8ZCKiJmZBcNQIL7ZBoth'
d$ = d$ + 'tRPaYRewp0tKA5soDzdHYGhevN3EtZAG3yJGIeRsIbzLaKBcsgMYQp5Am0wopQQ5qLEIJWranDa8FAAZD'

REQUESTHTTPX u$, m$, "Content-Type=application/x-www-form-urlencoded;", d$

ACTIONID% = GETSYS PRG, "ACTIONID"

END

FACEBOOK_CALLBACK:

eventId%= GETSYS PRG,"EVTINFO"
If eventId%=ACTIONID% Then
 SETSYS PRG, "ACTIONID", eventId%

 stat%=Getsys PRG,"ACTIONSTAT"
 If (stat%=0) Then
   answer$ = RESPONSEHTTPX "RESPONSE-BODY"    
   Print "FACEBOOK POST RESPONSE :" + answer$
 Endif
Endif

END

FUNCTION GETEMOTICON$()
//icon from http://fbicons.net/
 $curtime$ = TIME$
 $curhour$ = $curtime$(12 To 13)
 $curhour_int% = VAL($curhour$)
 
 IF $curhour_int% = 8 THEN
   $GETEMOTICON$ = CHR$(239) + CHR$(187) + CHR$(191) + CHR$(240) + CHR$(159) + CHR$(140) + CHR$(133) //sunrise
   RETURN
 ENDIF
 IF $curhour_int% = 20 THEN
   $GETEMOTICON$ = CHR$(239) + CHR$(187) + CHR$(191) + CHR$(240) + CHR$(159) + CHR$(140) + CHR$(135) //sunset
   RETURN
 ENDIF
 
 IF $curhour_int% > 20 OR $curhour_int% < 8 THEN
   $GETEMOTICON$ = CHR$(240) + CHR$(159) + CHR$(140) + CHR$(131) //night
   
 ELSE
 
   IF solarrad@ < 200 THEN
     $GETEMOTICON$ = CHR$(239) + CHR$(187) + CHR$(191) + CHR$(226) + CHR$(152) + CHR$(129) //cload
   ELSE
     $GETEMOTICON$ =  Chr$(226) + Chr$(152) + Chr$(128) //Sun
   ENDIF
 ENDIF
 
 IF rainofhourly@ > 0 THEN
    $GETEMOTICON$ = CHR$(239) + CHR$(187) + CHR$(191) + CHR$(226) + CHR$(152) + CHR$(148) //umbrella
 ENDIF
 

ENDFN



Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section

By the way, the Weather Station I have connected to my eWON is this one : http://www.conrad.be/ce/nl/product/12676...ion-WH2600
This Weather station is quite cheap and features a Web Server.  So pretty easy to read the data using BASIC or JAVA.
In my case, I have developed the following Java IoServer to get the Data from it : https://developer.ewon.biz/content/weath...-io-server
Reply



Possibly Related Threads…
18-05-2020, 05:25 PM
Last Post: simon
16-04-2020, 09:10 PM
Last Post: simon
14-04-2020, 08:53 PM
Last Post: simon
08-04-2020, 05:23 PM
Last Post: simon
  Creating Totaliser Within eWON Started by Josh
3 Replies - 1.299 Views
14-02-2020, 06:06 PM
Last Post: simon
  eWON and ThingWorx Started by simon
13 Replies - 6.945 Views
17-01-2020, 05:55 PM
Last Post: ltitel
07-01-2020, 03:34 PM
Last Post: simon
22-10-2019, 10:42 AM
Last Post: simon
03-09-2019, 02:08 PM
Last Post: simon
  MQTT eWon Flexy 205 Started by RFreist
3 Replies - 1.764 Views
18-07-2019, 12:30 PM
Last Post: simon



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy