<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stew West</title>
    <description>The latest articles on DEV Community by Stew West (@stewest).</description>
    <link>https://dev.to/stewest</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F531673%2Fb792e9d8-5962-43b7-88e8-75a012f89023.png</url>
      <title>DEV Community: Stew West</title>
      <link>https://dev.to/stewest</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stewest"/>
    <language>en</language>
    <item>
      <title>Arduino, JohnnyFive, Socket io and React</title>
      <dc:creator>Stew West</dc:creator>
      <pubDate>Wed, 22 Sep 2021 08:41:03 +0000</pubDate>
      <link>https://dev.to/stewest/arduino-johnnyfive-socket-io-and-react-42dg</link>
      <guid>https://dev.to/stewest/arduino-johnnyfive-socket-io-and-react-42dg</guid>
      <description>&lt;h1&gt;
  
  
  Johnny Five Node JS server with Socket io connecting Arduino to React
&lt;/h1&gt;

&lt;p&gt;I wanted to make my Arduino flash certain green or red LEDs, triggered by certain sensors and then show that in a React app at the same time. Also, in the React App web page, I wanted to click a button and then see that trigger LEDs on the Arduino. I found that one could use socket.io to do this, with the one Johnny Five JS node + Socket.io server talking to the Arduino and via socket.io talking to the React JS Node app.&lt;/p&gt;

&lt;p&gt;Find the full instructable here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instructables.com/Arduino-JohnnyFive-Socketio-and-React/" rel="noopener noreferrer"&gt;https://www.instructables.com/Arduino-JohnnyFive-Socketio-and-React/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, we're creating a mashup of:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/rwaldron/johnny-five" rel="noopener noreferrer"&gt;https://github.com/rwaldron/johnny-five&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.valentinog.com/blog/socket-react/" rel="noopener noreferrer"&gt;https://www.valentinog.com/blog/socket-react/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rwaldron/johnny-five#setup-and-assemble-arduino" rel="noopener noreferrer"&gt;https://github.com/rwaldron/johnny-five#setup-and-assemble-arduino&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Download Arduino IDE&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Plug in your Arduino or Arduino compatible microcontroller via USB&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the Arduino IDE, select: File &amp;gt; Examples &amp;gt; Firmata &amp;gt; StandardFirmataPlus&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** StandardFirmataPlus is available in Firmata v2.5.0 or greater&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click the "Upload" button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the upload was successful, the board is now prepared and you can close the Arduino IDE.&lt;/p&gt;

&lt;p&gt;From &lt;a href="https://github.com/stewest/j5-arduino-react" rel="noopener noreferrer"&gt;https://github.com/stewest/j5-arduino-react&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git clone &lt;a href="https://github.com/stewest/j5-arduino-react.git" rel="noopener noreferrer"&gt;https://github.com/stewest/j5-arduino-react.git&lt;/a&gt; and cd j5-arduino-react&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then each from their own separate terminal:&lt;/p&gt;

&lt;p&gt;Terminal 1:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cd socket-io-server&lt;/li&gt;
&lt;li&gt;yarn install&lt;/li&gt;
&lt;li&gt;node app.js&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Terminal 2:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cd socket-io-client&lt;/li&gt;
&lt;li&gt;yarn install&lt;/li&gt;
&lt;li&gt;yarn start&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While developing, as the client and server use specific ports, you may need to stop of all nodes and restart. - &lt;code&gt;killall -9 node&lt;/code&gt; in the socket-io-server folder and restart both the server &lt;code&gt;node app.js&lt;/code&gt; and &lt;code&gt;yarn start&lt;/code&gt; the client.&lt;/p&gt;

&lt;p&gt;If you find some lights not working, double check the pins assigned. I hope the Fritzing diagram helps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does it do?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You should see a Socket.io Button, that temporarily stops the client from connecting to the socket server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is a "light" sensor showing the amount of light data from from the photo resistor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the Arduino board first starts it has some LEDs flashing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The LED status is shown as on or off. Once the node server and react app has loaded, you should be able to click the Toggle LEDs button and the Red, Green and Blue LEDs should light up for 5 seconds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is a temperature display.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://johnny-five.io/api/led.rgb/" rel="noopener noreferrer"&gt;http://johnny-five.io/api/led.rgb/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://johnny-five.io/examples/photoresistor" rel="noopener noreferrer"&gt;http://johnny-five.io/examples/photoresistor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackabuse.com/using-global-variables-in-node-js/" rel="noopener noreferrer"&gt;https://stackabuse.com/using-global-variables-in-node-js/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.valentinog.com/blog/socket-react/" rel="noopener noreferrer"&gt;https://www.valentinog.com/blog/socket-react/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://socket.io/docs/v3/index.html" rel="noopener noreferrer"&gt;https://socket.io/docs/v3/index.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>johnnyfive</category>
      <category>react</category>
      <category>socketio</category>
    </item>
    <item>
      <title>GATSBY AND REACT INTERNATIONALISATION</title>
      <dc:creator>Stew West</dc:creator>
      <pubDate>Wed, 22 Sep 2021 08:17:23 +0000</pubDate>
      <link>https://dev.to/stewest/gatsby-and-react-internationalisation-59cn</link>
      <guid>https://dev.to/stewest/gatsby-and-react-internationalisation-59cn</guid>
      <description>&lt;p&gt;Great post by Mattia Simonato&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazeelabs.com/en/journal/gatsby-and-react-internationalisation" rel="noopener noreferrer"&gt;https://www.amazeelabs.com/en/journal/gatsby-and-react-internationalisation&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>GraphQL in Twig!</title>
      <dc:creator>Stew West</dc:creator>
      <pubDate>Tue, 06 Jul 2021 10:17:22 +0000</pubDate>
      <link>https://dev.to/stewest/graphql-in-twig-45en</link>
      <guid>https://dev.to/stewest/graphql-in-twig-45en</guid>
      <description>&lt;p&gt;In 2019 I presented "a beginner’s guide on how to use GraphQL in Twig" - to progressively decouple Drupal's Front end at Decoupled Days in New York.&lt;/p&gt;

&lt;p&gt;Decoupled Drupal is part of the future, but learning an entirely new stack can be daunting (like React, Vue or Angular, if you haven't used those before). &lt;/p&gt;

&lt;p&gt;Writing GraphQL inside Twig templates gives developers a path to an accessible soft-decoupled approach.&lt;/p&gt;

&lt;p&gt;This session will introduce GraphQL queries and demonstrate the advantages of changing the Drupal push model to a pull model by letting the template define its data requirements.&lt;/p&gt;

&lt;h1&gt;
  
  
  Quick Benefits
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Performance&lt;br&gt;
-- Everything done in the same GraphQL “request”,  no HTTP request is made.&lt;br&gt;
-- Queries are cached&lt;br&gt;
-- Queries are grouped within multiple templates&lt;br&gt;
-- Under the hood, it's like an additional hook&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Advantages&lt;br&gt;
-- We still get Drupal forms&lt;br&gt;
-- We still get translations out of the box&lt;br&gt;
-- We still get all the nice features as it ...&lt;br&gt;
-- Works alongside with standard Drupal&lt;br&gt;
-- We have a common language between Backend and Frontend!&lt;br&gt;
-- Reduced risk / cost&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the future: it is easier to partly decouple (ie: some React driven components), and it lays a foundation path to fully decouple. “Future proof”.&lt;/p&gt;

&lt;h1&gt;
  
  
  See the Presentation here.
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=lknMgevZqu0" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=lknMgevZqu0&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Links:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Soft decoupling with GraphQL + Twig: &lt;a href="https://www.youtube.com/watch?v=QsmeXMZ0foM" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=QsmeXMZ0foM&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Atomic design with GraphQL + Twig: &lt;a href="https://www.youtube.com/watch?v=9AJNp72-3D8" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=9AJNp72-3D8&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Drupal Europe presentation: &lt;a href="https://www.youtube.com/watch?v=BFf3stFHmk4" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=BFf3stFHmk4&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.drupal.org/project/graphql" rel="noopener noreferrer"&gt;https://www.drupal.org/project/graphql&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazeelabs.com/en/blog/using-twig-storybook-and-drupal" rel="noopener noreferrer"&gt;https://www.amazeelabs.com/en/blog/using-twig-storybook-and-drupal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazeelabs.com/en/blog/dont-push-it-using-graphql-twig" rel="noopener noreferrer"&gt;https://www.amazeelabs.com/en/blog/dont-push-it-using-graphql-twig&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://drupal.slack.com/" rel="noopener noreferrer"&gt;https://drupal.slack.com/&lt;/a&gt; #graphql&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>drupal</category>
      <category>graphql</category>
      <category>twig</category>
      <category>decouple</category>
    </item>
    <item>
      <title>The Future Web is here</title>
      <dc:creator>Stew West</dc:creator>
      <pubDate>Wed, 27 Jan 2021 09:24:53 +0000</pubDate>
      <link>https://dev.to/stewest/the-future-web-is-here-lik</link>
      <guid>https://dev.to/stewest/the-future-web-is-here-lik</guid>
      <description>&lt;p&gt;Join me by claiming your ticket here &lt;br&gt;
&lt;a href="https://gatsbyconf.com/conference-pass/Stewart-West/" rel="noopener noreferrer"&gt;https://gatsbyconf.com/conference-pass/Stewart-West/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>conference</category>
    </item>
  </channel>
</rss>
